-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into tuan-linh/initialize-hubble-stats
- Loading branch information
Showing
38 changed files
with
1,131 additions
and
246 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
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,42 @@ | ||
import { HexString } from '@polkadot/util/types'; | ||
|
||
export interface IVAnchorPublicInputs { | ||
proof: HexString; | ||
roots: HexString[]; | ||
inputNullifiers: HexString[]; | ||
outputCommitments: [HexString, HexString]; | ||
publicAmount: HexString; | ||
extDataHash: HexString; | ||
} | ||
|
||
export interface Groth16Proof { | ||
proof: { | ||
pi_a: string[]; | ||
pi_b: string[][]; | ||
pi_c: string[]; | ||
curve: string; | ||
prococol: 'groth16'; | ||
}; | ||
publicSignals: string[]; | ||
} | ||
|
||
export interface VAnchorGroth16ProofInput { | ||
roots: bigint[]; | ||
chainID: bigint; | ||
inputNullifier: bigint[]; | ||
outputCommitment: bigint[]; | ||
publicAmount: bigint; | ||
extDataHash: bigint; | ||
|
||
inAmount: bigint[]; | ||
inPrivateKey: bigint[]; | ||
inBlinding: bigint[]; | ||
inPathIndices: bigint[]; | ||
inPathElements: bigint[][]; | ||
|
||
// data for 2 transaction outputs | ||
outChainID: bigint[]; | ||
outAmount: bigint[]; | ||
outPubkey: bigint[]; | ||
outBlinding: bigint[]; | ||
} |
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,11 @@ | ||
import { HexString } from '@polkadot/util/types'; | ||
|
||
const ensureHex = (maybeHex: string): HexString => { | ||
if (maybeHex.startsWith('0x')) { | ||
return maybeHex as `0x${string}`; | ||
} | ||
|
||
return `0x${maybeHex}`; | ||
}; | ||
|
||
export default ensureHex; |
20 changes: 20 additions & 0 deletions
20
libs/polkadot-api-provider/src/utils/getVAnchorExtDataHash.ts
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,20 @@ | ||
import { IVariableAnchorExtData } from '@webb-tools/interfaces'; | ||
import { FIELD_SIZE } from '@webb-tools/sdk-core'; | ||
import { ethers } from 'ethers'; | ||
import ensureHex from './ensureHex'; | ||
|
||
const getVAnchorExtDataHash = (extData: IVariableAnchorExtData): bigint => { | ||
const abi = new ethers.utils.AbiCoder(); | ||
const encodedData = abi.encode( | ||
[ | ||
'(bytes recipient,int256 extAmount,bytes relayer,uint256 fee,uint256 refund,bytes token,bytes encryptedOutput1,bytes encryptedOutput2)', | ||
], | ||
[extData] | ||
); | ||
|
||
const hash = ethers.utils.keccak256(encodedData); | ||
|
||
return BigInt(ensureHex(hash)) % FIELD_SIZE.toBigInt(); | ||
}; | ||
|
||
export default getVAnchorExtDataHash; |
Oops, something went wrong.