Skip to content

Commit a731a51

Browse files
Junirezzcursoragent
andcommitted
fix: restore 64-byte Ristretto hashToCurve for pedersen generators
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent de5daf9 commit a731a51

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

shared/src/crypto/pedersen.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ function groupOrder(): bigint {
88
return RISTRETTO_ORDER;
99
}
1010

11-
const G = RistrettoPoint.hashToCurve(sha256(new TextEncoder().encode(DOMAIN_PREFIX + '-G')));
12-
const H = RistrettoPoint.hashToCurve(sha256(new TextEncoder().encode(DOMAIN_PREFIX + '-H')));
11+
function hashToRistrettoPoint(seed: string) {
12+
const h1 = sha256(new TextEncoder().encode(seed));
13+
const h2 = sha256(h1);
14+
const combined = new Uint8Array(64);
15+
combined.set(h1, 0);
16+
combined.set(h2, 32);
17+
return RistrettoPoint.hashToCurve(combined);
18+
}
19+
20+
const G = hashToRistrettoPoint(DOMAIN_PREFIX + '-G');
21+
const H = hashToRistrettoPoint(DOMAIN_PREFIX + '-H');
1322

1423
export interface PedersenCommitment {
1524
commitment: string;

0 commit comments

Comments
 (0)