Skip to content

Commit

Permalink
add instructions to create hash-to-point reference values, remove old…
Browse files Browse the repository at this point in the history
… TODO
  • Loading branch information
kevincharm committed Feb 12, 2024
1 parent 0e5cda6 commit 9807758
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pairing/bn254/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func hashToPoint(domain, m []byte) kyber.Point {

func hashToField(domain, m []byte) (*big.Int, *big.Int) {
const u = 48
_msg := expandMsgXmd(domain, m, 2*u) // TODO: Handle err/panic
_msg := expandMsgXmd(domain, m, 2*u)
x := new(big.Int)
y := new(big.Int)
x.SetBytes(_msg[0:48]).Mod(x, p)
Expand Down
4 changes: 4 additions & 0 deletions pairing/bn254/point_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ func TestHashToPoint(t *testing.T) {
montDecode(x, &p.g.x)
montDecode(y, &p.g.y)

// Reference values are taken from:
// https://github.com/kevincharm/bls-bn254/blob/bef9dad5d99b3c99a17fd85e3328daea5824dac9/scripts/hash.ts
// Clone the repo, run `yarn` to install deps, then run:
// yarn bls:hash 0xd3420d154786d7dc15997457c4598fa14f9345bb5157b14bb8bfbad3816cbf84
if x.String() != "298a790a58f3f0595879f168f410acd0c78537f5879ad087a24f3d3797f10d31" {
t.Error("hashToPoint x does not match ref")
}
Expand Down

0 comments on commit 9807758

Please sign in to comment.