Skip to content

Commit

Permalink
Ⓜ️ Mina Schnorr imza tipini ekle (fixes #18)
Browse files Browse the repository at this point in the history
  • Loading branch information
oemerfurkan authored Mar 20, 2024
1 parent 59b1316 commit 80ef645
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions did/section.d.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ did.Section.prototype.bls12_381;
*/
did.Section.prototype.secp256k1;

/**
* The Schnorr signatures kept as a list of 64 bytes compact signatures,
* sorted in lex order.
*
* Each signature must be from a different (valid) signer node.
*
* @type {Array<string>}
*/
did.Section.prototype.minaSchnorr;

/**
* Contains the fundamental identification data of a person such as
* name, date of birth, national id etc.
Expand Down
4 changes: 2 additions & 2 deletions did/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const hash = (sectionName, section) => {
}
}
/** @const {!Set<string>} */
const notHashed = new Set(["secp256k1", "bls12_381", "commitmentR"]);
const notHashed = new Set(["secp256k1", "minaSchnorr", "bls12_381", "commitmentR"]);
return keccak256(
KIMLIKDAO_HASH_PREFIX + JSON.stringify(section,
Object.keys(section).filter((x) => !notHashed.has(x)).sort())
Expand Down Expand Up @@ -121,7 +121,7 @@ const signSection = (sectionName, section, commitment, signatureTs, privateKey)
const d = BigInt("0x" + hash(sectionName, section));
let { r, s, yParity } = sign(d, privateKey);
if (yParity) s += (1n << 255n);
section.secp256k1 = [evm.uint256(r) + evm.uint256(s)];
section.secp256k1 = section.minaSchnorr = [evm.uint256(r) + evm.uint256(s)];
}

export {
Expand Down

0 comments on commit 80ef645

Please sign in to comment.