From cb5c579ae46ee0570f2f32408e0427f989bd33ab Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Fri, 29 Apr 2022 15:08:53 +0200 Subject: change 'preimage' to 'message' Issue: #40 --- cmd/tmp/submit/main.go | 8 ++++---- integration/test.sh | 6 +++--- pkg/db/trillian.go | 2 +- pkg/db/trillian_test.go | 2 +- pkg/instance/handler_test.go | 6 +++--- pkg/instance/instance.go | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/tmp/submit/main.go b/cmd/tmp/submit/main.go index e688284..ff7a353 100644 --- a/cmd/tmp/submit/main.go +++ b/cmd/tmp/submit/main.go @@ -15,7 +15,7 @@ import ( var ( shardHint = flag.Uint64("shard_hint", 0, "shard hint (decimal)") - preimage = flag.String("preimage", "", "preimage (hex)") + message = flag.String("message", "", "message (hex)") sk = flag.String("sk", "", "secret key (hex)") domainHint = flag.String("domain_hint", "example.com", "domain hint (string)") base_url = flag.String("base_url", "localhost:6965/testonly", "base url (string)") @@ -29,8 +29,8 @@ func main() { mustDecodeHex(*sk, priv[:]) var p types.Hash - if *preimage != "" { - mustDecodeHex(*preimage, p[:]) + if *message != "" { + mustDecodeHex(*message, p[:]) } else { mustPutRandom(p[:]) } @@ -41,7 +41,7 @@ func main() { } sig := ed25519.Sign(priv, msg.ToBinary()) - fmt.Printf("echo \"shard_hint=%d\npreimage=%x\nsignature=%x\nverification_key=%x\ndomain_hint=%s\" | curl --data-binary @- %s/sigsum/v0/add-leaf\n", + fmt.Printf("echo \"shard_hint=%d\nmessage=%x\nsignature=%x\nverification_key=%x\ndomain_hint=%s\" | curl --data-binary @- %s/sigsum/v0/add-leaf\n", *shardHint, p[:], sig, diff --git a/integration/test.sh b/integration/test.sh index 0a5dd78..7ba9dc9 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -344,8 +344,8 @@ function test_get_leaf() { return fi - preimage=$(openssl dgst -binary <(echo $1) | base16) - checksum=$(openssl dgst -binary <(echo $preimage | base16 -d) | base16) + message=$(openssl dgst -binary <(echo $1) | base16) + checksum=$(openssl dgst -binary <(echo $message | base16 -d) | base16) if [[ $(value_of checksum) != $checksum ]]; then fail "$desc: wrong checksum $(value_of checksum)" return @@ -362,7 +362,7 @@ function test_get_leaf() { function test_add_leaf() { desc="POST add-leaf (data \"$1\")" echo "shard_hint=$ssrv_shard_start" > $log_dir/req - echo "preimage=$(openssl dgst -binary <(echo $1) | base16)" >> $log_dir/req + echo "message=$(openssl dgst -binary <(echo $1) | base16)" >> $log_dir/req echo "signature=$(echo $1 | sigsum-debug leaf sign -k $cli_priv -h $ssrv_shard_start)" >> $log_dir/req echo "verification_key=$cli_pub" >> $log_dir/req diff --git a/pkg/db/trillian.go b/pkg/db/trillian.go index 34501b9..97f1305 100644 --- a/pkg/db/trillian.go +++ b/pkg/db/trillian.go @@ -26,7 +26,7 @@ func (c *TrillianClient) AddLeaf(ctx context.Context, req *requests.Leaf) error leaf := types.Leaf{ Statement: types.Statement{ ShardHint: req.ShardHint, - Checksum: *types.HashFn(req.Preimage[:]), + Checksum: *types.HashFn(req.Message[:]), }, Signature: req.Signature, KeyHash: *types.HashFn(req.VerificationKey[:]), diff --git a/pkg/db/trillian_test.go b/pkg/db/trillian_test.go index 0010e32..9a390a1 100644 --- a/pkg/db/trillian_test.go +++ b/pkg/db/trillian_test.go @@ -21,7 +21,7 @@ import ( func TestAddLeaf(t *testing.T) { req := &requests.Leaf{ ShardHint: 0, - Preimage: types.Hash{}, + Message: types.Hash{}, Signature: types.Signature{}, VerificationKey: types.PublicKey{}, DomainHint: "example.com", diff --git a/pkg/instance/handler_test.go b/pkg/instance/handler_test.go index b3af666..0b81f6c 100644 --- a/pkg/instance/handler_test.go +++ b/pkg/instance/handler_test.go @@ -662,7 +662,7 @@ func mustHandle(t *testing.T, i Instance, e types.Endpoint) Handler { return Handler{} } -func mustLeafBuffer(t *testing.T, shardHint uint64, preimage types.Hash, wantSig bool) io.Reader { +func mustLeafBuffer(t *testing.T, shardHint uint64, message types.Hash, wantSig bool) io.Reader { t.Helper() vk, sk, err := ed25519.GenerateKey(rand.Reader) @@ -671,7 +671,7 @@ func mustLeafBuffer(t *testing.T, shardHint uint64, preimage types.Hash, wantSig } msg := types.Statement{ ShardHint: shardHint, - Checksum: *types.HashFn(preimage[:]), + Checksum: *types.HashFn(message[:]), } sig := ed25519.Sign(sk, msg.ToBinary()) if !wantSig { @@ -680,7 +680,7 @@ func mustLeafBuffer(t *testing.T, shardHint uint64, preimage types.Hash, wantSig return bytes.NewBufferString(fmt.Sprintf( "%s=%d\n"+"%s=%x\n"+"%s=%x\n"+"%s=%x\n"+"%s=%s\n", "shard_hint", shardHint, - "preimage", preimage[:], + "message", message[:], "signature", sig, "verification_key", vk, "domain_hint", "example.com", diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 77f2e5b..18255a1 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -63,7 +63,7 @@ func (i *Instance) leafRequestFromHTTP(ctx context.Context, r *http.Request) (*r } stmt := types.Statement{ ShardHint: req.ShardHint, - Checksum: *types.HashFn(req.Preimage[:]), + Checksum: *types.HashFn(req.Message[:]), } if !stmt.Verify(&req.VerificationKey, &req.Signature) { return nil, fmt.Errorf("invalid signature") -- cgit v1.2.3