Skip to content

Remove unnecessary "Random" command when signing.#15

Open
ke6jjj wants to merge 1 commit intomasterfrom
jsc/optimize-signing
Open

Remove unnecessary "Random" command when signing.#15
ke6jjj wants to merge 1 commit intomasterfrom
jsc/optimize-signing

Conversation

@ke6jjj
Copy link
Copy Markdown

@ke6jjj ke6jjj commented Nov 9, 2022

It is not neccessary to invoke the "GenRandom" command before requesting an ECDSA signature. This command does not generate the nonce (random value "k") that is required for ECDSA -- that is performed internally by the ECC508/ECC608 and always has been.

By removing this unnecessary command it should be possible to generate signatures in less time than before.

Status

I tested signature generation with this branch and confirmed that it generates a correct signature for the message <<"hello">> using the ECC608 on an sidetable_v1 OG unit.

It is not neccessary to invoke the "GenRandom" command before
requesting an ECDSA signature. This command does not generate the
nonce (random value "k") that is required for ECDSA -- that is
performed internally by the ECC508/ECC608 and always has been.

By removing this unnecessary command it should be possible to
generate signatures in less time than before.
@ke6jjj
Copy link
Copy Markdown
Author

ke6jjj commented Nov 10, 2022

Round-trip test procedure

You can use the following round-trip test to confirm that this branch produces usable, correct signatures.

Prerequisites

  • A development machine with an ATECC608 attached via I2C.
  • Erlang/OTP
  • A copy of this repository.
  • A copy of the libp2p-crypto repository.

Steps

  1. Check out this test branch of the ecc508 repository
  2. Invoke ./rebar3 shell (the rebar3 executable in this repository is quite old, consider copying rebar3 from elsewhere)
  3. Start up the process and generate a signature on the message <<"hello">>
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
1> {ok, Pid} = ecc508:start_link().
{ok,<0.229.0>}
2> ecc508:wake(Pid), {ok, Sig} = ecc508:sign(Pid, 0, <<"hello">>).
{ok,<<48,...>>}
3> rp(Sig).
<<SAVE-THIS>>
  1. Save the signature bytes and shut down the shell.
  2. Obtain the b58 form of the ECC608 public key. Example: 112VYECRxdyUixsN3KyTMdJaNdGGNF6UARwS5Pkyi86xoiBkSyLU
  3. Invoke ./rebar3 shell in the libp2p-crypto repository
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
1> Sig = <<SAVED-SIGNATURE-ABOVE>>.
<<48,...>>
2> PubKey = libp2p_crypto:b58_to_pubkey("112VYECRxdyUixsN3KyTMdJaNdGGNF6UARwS5Pkyi86xoiBkSyLU").
{ecc_compact,{{'ECPoint',<<4,196,126,252,69,98,75,22,54,
                           8,245,151,245,120,179,249,158,
                           197,6,96,75,159,202,15,...>>},
              {namedCurve,{1,2,840,10045,3,1,7}}}}
3> libp2p_crypto:verify(<<"hello">>, Sig, PubKey).
true

@ke6jjj ke6jjj requested a review from madninja November 15, 2022 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant