Closed mahnunchik closed 1 year ago
Length of Fp.bytes are for compatibility with libsecp256k1: https://github.com/bitcoin-core/secp256k1/blob/67214f5f7d8e0bdf193ceb1f47ba8277d1a0871a/src/secp256k1.c#L476
Because the arguments have distinct fixed lengths it is not possible for different argument mixtures to emulate each other and result in the same nonces.
Do you need longer value for something, or this is just fixing spec non-compliance?
I'm moving from our lovely elliptic
module...
For the EOS crypto 1 byte additional data is used. So I checked the spec and realized that it is not mandatory for additional data to be 32 bytes.
According to the comment from libsecp256k1 https://github.com/bitcoin-core/secp256k1/blob/67214f5f7d8e0bdf193ceb1f47ba8277d1a0871a/src/secp256k1.c#L477 additional 16 bytes may be appended too.
For the EOS crypto 1 byte additional data is used. So I checked the spec and realized that it is not mandatory for additional data to be 32 bytes.
if the byte is e.g. de
, you can do this: 00000000000000000000000000000000000000000000000000000000000000de
. Does this work?
With regards to 16-byte algorithm name: that's true. I did not add it, because extraEntropy is used for low-r
signatures, which is common in btc, while algo16 does not seem to be popular.
Yes, it is possible to produce valid EOS signature by using 00000000000000000000000000000000000000000000000000000000000000de
but not the same signature as original EOS code produces.
I think it is better to follow specification and check that extraEntropy
is bytes but not check the size.
I agree with you.
but not the same signature as original EOS code produces
That's weird. I would have thought they are the same - which would have worked for now.
Could you add a test for this, please?
@mahnunchik ping
@paulmillr done
Why was .json changed? I think we're having it in repo because it was copied from some other library. Can't we test the dynamic size without changing json?
Yep, additional test may be added just to test different entropy sizes.
Ok, please add it and revert json change and we'll be good to go.
@paulmillr please check the changes
55