-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed range proof approach, normalization and tests
- Loading branch information
Showing
17 changed files
with
131 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
|
||
export * from "./aptos"; | ||
export * from "./aptosConfig"; | ||
export * from "./veiledCoin"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export interface RangeProofInputs { | ||
v: bigint; | ||
r: Uint8Array; | ||
valBase: Uint8Array; | ||
randBase: Uint8Array; | ||
bits?: number; | ||
} | ||
|
||
export interface VerifyRangeProofInputs { | ||
proof: Uint8Array; | ||
commitment: Uint8Array; | ||
valBase: Uint8Array; | ||
randBase: Uint8Array; | ||
bits?: number; | ||
} | ||
|
||
export class RangeProofExecutor { | ||
/** | ||
* Generate range Zero Knowledge Proof | ||
* | ||
* @param opts.v The value to create the range proof for | ||
* @param opts.r A vector of bytes representing the blinding scalar used to hide the value. | ||
* @param opts.valBase A vector of bytes representing the generator point for the value. | ||
* @param opts.randBase A vector of bytes representing the generator point for the randomness. | ||
* @param opts.bits Bits size of value to create the range proof | ||
*/ | ||
static generateRangeZKP: (opts: RangeProofInputs) => Promise<{ proof: Uint8Array; commitment: Uint8Array }>; | ||
|
||
/** | ||
* Verify range Zero Knowledge Proof | ||
* | ||
* @param opts.proof A vector of bytes representing the serialized range proof to be verified. | ||
* @param opts.commitment A vector of bytes representing the Pedersen commitment the range proof is generated for. | ||
* @param opts.valBase A vector of bytes representing the generator point for the value. | ||
* @param opts.randBase A vector of bytes representing the generator point for the randomness. | ||
* @param opts.bits Bits size of the value for range proof | ||
*/ | ||
static verifyRangeZKP: (opts: VerifyRangeProofInputs) => Promise<boolean>; | ||
|
||
static setGenerateRangeZKP(func: (opts: RangeProofInputs) => Promise<{ proof: Uint8Array; commitment: Uint8Array }>) { | ||
this.generateRangeZKP = func; | ||
} | ||
|
||
static setVerifyRangeZKP(func: (opts: VerifyRangeProofInputs) => Promise<boolean>) { | ||
this.verifyRangeZKP = func; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export * from "./rangeProof"; | ||
export * from "./veiledKeyRotation"; | ||
export * from "./veiledNormalization"; | ||
export * from "./veiledTransfer"; | ||
export * from "./veiledWithdraw"; | ||
export * from "./veiledAmount"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Account, Ed25519PrivateKey, TwistedEd25519PrivateKey } from "../../../src"; | ||
|
||
describe("Decryption key derivation from Private key", () => { | ||
it("Should derive decryption key from private key", () => { | ||
const alice = Account.fromPrivateKey({ | ||
privateKey: new Ed25519PrivateKey("0x9d7669b01809f7486e1710c2050b2aa48fc05f68159e9654277be7490470eb16"), | ||
}); | ||
|
||
const signature = alice.sign(TwistedEd25519PrivateKey.decryptionKeyDerivationMessage); | ||
|
||
const aliceDecryptionKey = TwistedEd25519PrivateKey.fromSignature(signature); | ||
|
||
expect(aliceDecryptionKey.toString()).toEqual("0x9d4c06efdf5a4ea056cc7c9c17137c3f89bb868f9c3ec5b0d3de0bc1d963cf0a"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.