Skip to content

Commit

Permalink
add test for stealth private key computation
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign committed Dec 17, 2023
1 parent 74e4b5e commit 511fa7f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/stealth_address.zig
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,12 @@ test "generate and check" {
const ok = try EIP5564.checkStealthAddress(ga.stealth_address, ga.ephemeral_pubkey, wrong_viewing_key, spending_pubkey, ga.view_tag +% 1);
try std.testing.expect(!ok);
}

// Compute stealth key and verify with expected stealth address.
{
const got_privkey = try EIP5564.computeStealthKey(ga.ephemeral_pubkey, viewing_key, spending_key);
const got_stealth_addr_point = try Secp256k1.mul(Secp256k1.basePoint, got_privkey, Endian.Big);
const got_eth_addr = EIP5564.pointToEthAddr(got_stealth_addr_point);
try std.testing.expect(std.mem.eql(u8, &ga.stealth_address, &got_eth_addr));
}
}

0 comments on commit 511fa7f

Please sign in to comment.