-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ed25519 precompile in eth clients #3
Comments
Looks like the main thing will be: as Ed25519 is not available in Solidity as a precompiled function (such as ecrecover) we will need to provide it ourself while minimizing gas consumption of the resulting function. Eg a SHA1 implemention (linked below): "It requires roughly 56k gas per 512 bit block hashed." Here are some noteworthy pointers: |
Here is my SO question touching on the topic: And here is the PR for merging an EIP to add Ed25519 signature verification as a precompiled contract to the EVM: |
next step: get it on the agenda of an ethereum core devs meeting: ethereum/pm#36 (comment) |
Rgd implementation in cpp-ethereum, here are some hints I dug out:
precompiled.insert(make_pair(Address(1), PrecompiledContract(3000, 0, PrecompiledRegistrar::executor("ecrecover"))));
precompiled.insert(make_pair(Address(2), PrecompiledContract(60, 12, PrecompiledRegistrar::executor("sha256"))));
precompiled.insert(make_pair(Address(3), PrecompiledContract(600, 120, PrecompiledRegistrar::executor("ripemd160"))));
precompiled.insert(make_pair(Address(4), PrecompiledContract(15, 3, PrecompiledRegistrar::executor("identity"))));
|
ChainParams::ChainParams()
{
for (unsigned i = 1; i <= 4; ++i)
genesisState[Address(i)] = Account(0, 1);
// Setup default precompiled contracts as equal to genesis of Frontier.
precompiled.insert(make_pair(Address(1), PrecompiledContract(3000, 0, PrecompiledRegistrar::executor("ecrecover"))));
precompiled.insert(make_pair(Address(2), PrecompiledContract(60, 12, PrecompiledRegistrar::executor("sha256"))));
precompiled.insert(make_pair(Address(3), PrecompiledContract(600, 120, PrecompiledRegistrar::executor("ripemd160"))));
precompiled.insert(make_pair(Address(4), PrecompiledContract(15, 3, PrecompiledRegistrar::executor("identity"))));
} |
|
https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go#L49 // PrecompiledContractsByzantium contains the default set of pre-compiled Ethereum
// contracts used in the Byzantium release.
var PrecompiledContractsByzantium = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{1}): &ecrecover{},
common.BytesToAddress([]byte{2}): &sha256hash{},
common.BytesToAddress([]byte{3}): &ripemd160hash{},
common.BytesToAddress([]byte{4}): &dataCopy{},
common.BytesToAddress([]byte{5}): &bigModExp{},
common.BytesToAddress([]byte{6}): &bn256Add{},
common.BytesToAddress([]byte{7}): &bn256ScalarMul{},
common.BytesToAddress([]byte{8}): &bn256Pairing{},
} |
The core of the subject is about associating eth-secp256k1 and ed25519 public keys with each other by cross-signing, and then be able to check such cross-signatures within contracts. On the classic EVM, this is too costly without a precompile. Adding one is what the task list below is about.
Task list: Note: above is missing actual unit tests (test vectors) still - only the test skeletons are there. |
ok, from eth core devs chatting, we need 2 things to move this forward:
the EIP 665 text could also be more precise:
|
rgd the choice of ed25519 implementation that can be trusted and that is available over all major eth clients: seem good. for Python, above 2 libraries are available via CFFI wrappers: then there is HACL, and a possible implementation based on that: https://gist.github.com/oberstet/ef534c0cd060d0b9bd15a9e4a2529efb footprint (stripped) of libsec256k1 and libsodium shared libraries (here, builds used with Python/cffi).
(cpy365_3) oberstet@thinkpad-t430s:~/scm/xbr/xbr-network$ ll /home/oberstet/cpy365_2/lib/python3.6/site-packages/nacl/_sodium.abi3.so
-rwxrwxr-x 1 oberstet oberstet 353064 Apr 15 06:43 /home/oberstet/cpy365_2/lib/python3.6/site-packages/nacl/_sodium.abi3.so*
(cpy365_3) oberstet@thinkpad-t430s:~/scm/xbr/xbr-network$ ll /home/oberstet/cpy365_2/lib/python3.6/site-packages/coincurve/_libsecp256k1.cpython-36m-x86_64-linux-gnu.so
-rwxrwxr-x 1 oberstet oberstet 196736 Apr 15 06:45 /home/oberstet/cpy365_2/lib/python3.6/site-packages/coincurve/_libsecp256k1.cpython-36m-x86_64-linux-gnu.so*
(cpy365_3) oberstet@thinkpad-t430s:~/scm/xbr/xbr-network$ |
@oberstet Hello there! Is anything blocking your use of |
@ofek coincurve doesn't support ed25519 as far as I see .. however, I am closing this issue anyways, as we don't need ed25519 at this point - and since EIP665 never got into production anyways |
moved from https://github.com/xbr/xbr-network/issues/13
needed in https://github.com/xbr/xbr-network/issues/8, and there is only ECDSA built in.
The latest Ethereum hard fork should have brought the features needed in Solidity (or the VM under the hood) to implement Ed25519, which is used by WAMP-cryptosign and WAMP-cryptobox.
https://ethereum.stackexchange.com/questions/42771/ed25519-in-smart-contracts
The text was updated successfully, but these errors were encountered: