Set of functions useful when working with the commitments generated by SealHub
Create a message to sign
getSealHubValidatorInputs(signature: string, message: string, provider?: Provider, commitments?: (bigint | string)[])
Generates an input to create a zk proof
Parameters
message: string
— a message created using thegetMessage()
functionsignature: string
— signature made bywallet.signMessage(message)
provider?: Provider
— abstract Ethereum providercommitments?: (bigint | string)[]
— previously added commitments in the contract
Returns
{
U: string[][]
s: string[]
address: string
pathIndices: number[]
siblings: string[]
}
Example
import { Wallet, providers } from 'ethers'
import {
getMessage,
getSealHubValidatorInputs,
} from '@big-whale-labs/seal-hub-kit'
const provider = new providers.InfuraProvider('goerli')
async function zkInput() {
const wallet = Wallet.createRandom()
const message = getMessage()
const signature = await wallet.signMessage(message)
return getSealHubValidatorInputs(signature, message, provider)
}
zkInput()
Generates an input to create a commitment's zk proof
Parameters
signature: string
— signature made bywallet.signMessage(message)
message: string
— a message created using thegetMessage()
function
Returns
{
U: string[][]
s: string[]
scalarForT: string[]
TPrecomputes: string[][][][]
T: string[][]
rInv: string[]
}
Create a commitment based on the message and signature
Parameters
signature: string
— signature made bywallet.signMessage(message)
message: string
— a message created using thegetMessage()
function
Example
import { Wallet } from 'ethers'
import {
getMessage,
getCommitmentFromSignature,
} from '@big-whale-labs/seal-hub-kit'
async function createCommitment() {
const wallet = Wallet.createRandom()
const message = getMessage()
const signature = await wallet.signMessage(message)
return getCommitmentFromSignature(signature, message)
}
Checks for a commitment in the SealHub contract
Parameters
commitment: string | bigint
— hash generated bygetCommitmentFromSignature
provider: Provider
— abstract Ethereum provider
yarn start
— development mode, rebuilds on changesyarn build
— builds utilsyarn release
— create a release and publish the package