7

Block producers use SHA-256 to generate the digest and ECDSA to sign the block. Producers may sign using a K1 key (secp256k1 curve, used by Bitcoin) or an R1 key (P-256 curve, a NIST standard). Likewise, users may use K1 or R1 keys to sign transactions.


7

Here's how the C++ code calculates the block digest: digest_type::hash(*this) serializes the block into a binary form, then runs the binary through sha-256. block.hpp#L125 identifies the order that the fields are serialized in. The types of these fields is at block.hpp#L18 Each type has its own serialization procedure. Most of them live in libraries/fc. ...


4

Yes! It's very much possible! Look at the Dice contract example on the eosio github or in the repo folder eos/contracts/dice The function shown is a sha256 hashing method called sha256( ) Link to the actual dice.cpp file containing it's use on github: The Eosio example dice.cpp file


3

Yes, but you would encrypt and decrypt off-chain while only storing the encrypted data and other necessary data in the blockchain state. With eosjs, you can use the following set of commands to encrypt and decrypt data: // The message that will be encrypted let message = "my message" // For example purposes, this is the keypar of the recipient. Note I ...


3

Private Keys are typically encoded using WIF (Wallet Import Format). The Public Keys are likewise encoded in WIF format, but with the EOS prefix added to them. To obtain the actual ECC keys, the keys are decoded, verified against their embedded checksums, then converted into their binary formats.


2

The encryption is sha256 hash with a 32 byte buffer or string with encoding defaulting to UTF-8. Here's a link to the official repository for the elliptic curve functions which should be able to give you some more insight into how it works: https://github.com/EOSIO/eosjs-ecc Further if your question is relating the the registration of the tokens, I highly ...


2

There's a crypto.h inside of the contracts/eosiolib folder that has SHA/ripemd methods. AES should be done off-chain though since the cleartext would be visible to anyone replaying the blockchain and viewing the action arguments.


2

Check the output of JSON.stringify, I think you'll be surprised to see that it adds quotation marks around the string. "Hello" is not the same as JSON.stringify("Hello") JSON.stringify("Hello")=="\"Hello\""


2

xxd make a hexdump or do the reverse -r revert, convert hexdump into binary -p output 'plain hexdump style' sha256sum compute and check SHA256 message digest -b read in binary mode Here the combination of -r -p options for the xxd command will read plain hexadecimal dumps without line number information and without a particular column layout ...


2

Bitcoin, Ethereum or EOS uses secp256k1 algorithm. Not approximately, but exactly same. You can derive Ethereum address from EOS private key and sign Ethereum transaction. One difference between EOS and others, EOS supports secp256r1 a.k.a prime-256 which is NIST standard and supported by Android or iOS platform libraries. You can find there are two types of ...


1

As the link in your comment explain, 0x80 prefix is Bitcoin convention. (indicating Bitcoin mainnet) Due to characteristics of elliptic curve, there are only two points which share same x-coordinate. It means that, if you know x-coordinate and sign of y-coordinate, you can derive complete pair of x- and y-coordinate. That's compressed public key. (Oppositely,...


1

EOS also uses Elliptic curve cryptography for more you can refer https://github.com/EOSIO/eosjs-ecc


1

Don't really get what you're trying to build but here's the cryptoapi.


1

Some sexy dude made this library https://github.com/dtrades/dtrades-communication Let's you encrypt a string with a public key, decrypt with the corresponding private. import { encrypt, decrypt } from 'eos-communication-lib'; const public_key = "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"; const private_key = "...


1

Yes, it is possible. Please see here: https://github.com/EOSIO/eos/blob/master/contracts/eosiolib/crypto.h Developers can also compile their favourite C/C++ crypto library to do things EOSIO natively doesn't support.


1

The operations in contracts should be as short as possible. Because it’s directly pertain to the block producing time. I recommend you to do cryptographic things outside of contract and pass the results as binary to the contract.


Only top voted, non community-wiki answers of a minimum length are eligible