Documentation
¶
Index ¶
- Constants
- Variables
- func EthGnosisRecoverSigner(sig []byte, digest []byte) (*ethCommon.Address, error)
- func EthGnosisSign(msg []byte, key *ecdsa.PrivateKey) ([]byte, error)
- func EthGnosisSignDigest(digest []byte, key *ecdsa.PrivateKey) ([]byte, error)
- func EthGnosisVerify(sig []byte, msg []byte, address []byte) error
- func EthGnosisVerifyDigest(sig []byte, digest []byte, address []byte) error
- func EthZeppelinSign(msg []byte, key *ecdsa.PrivateKey) ([]byte, error)
- func GenGnosisSafeTx(to, safe string, value int64, data hexutil.Bytes, chainID int64, nonce int64) (*core.GnosisSafeTx, []byte, error)
- func GenPostRewardTxData(root []byte, amount *big.Int) ([]byte, error)
- func GenRewardMerkleTree(users []string, amounts []*big.Int, contractAddress string, ...) ([]byte, []byte, error)
- func GetLeafAddresses(mtreeJson string) ([]string, error)
- func GetMTreeProof(mtreeJson []byte, addr string) (root []byte, proof [][]byte, leafHash []byte, blockHash []byte, ...)
Constants ¶
const GnosisSafeSigLength = ethCrypto.SignatureLength
Variables ¶
var ( // MerkleLeafEncoding is (recipient, amount, contract_address, kwil_block_hash). // There is no point to add `kwil_chain_id` in the leaf encoding, as we cannot // enforce the uniqueness of it. MerkleLeafEncoding = []string{smt.SOL_ADDRESS, smt.SOL_UINT256, smt.SOL_ADDRESS, smt.SOL_BYTES32} )
Functions ¶
func EthGnosisRecoverSigner ¶
func EthGnosisSign ¶
func EthGnosisSign(msg []byte, key *ecdsa.PrivateKey) ([]byte, error)
EthGnosisSign generate a Gnosis(>1.3.0) signature, which is 65-byte in [R || S || V] format where V is 31 or 32. The message is the original message.
The Safe's expected V value for ECDSA signature is: - 27 or 28, for eth_sign - 31 or 32 if the message was signed with a EIP-191 prefix. Should be calculated as ECDSA V value + 4 Some wallets do that, some wallets don't, V > 30 is used by contracts to differentiate between prefixed and non-prefixed messages. The only way to know if the message was signed with a prefix is to check if the signer address is the same as the recovered address. More info: https://docs.safe.global/advanced/smart-account-signatures SDK: safe-core-sdk/packages/protocol-kit/src/utils/signatures/utils.ts `adjustVInSignature`
Since we use EIP-191, the V should be 31(0x1f) or 32(0x20).
func EthGnosisSignDigest ¶
func EthGnosisSignDigest(digest []byte, key *ecdsa.PrivateKey) ([]byte, error)
func EthGnosisVerify ¶
EthGnosisVerify verify the given message to the Gnosis(>1.3.0) signature, which is 65-byte in [R || S || V] format and V is 31(0x1f) or 32(0x20).
func EthGnosisVerifyDigest ¶
func EthZeppelinSign ¶
func EthZeppelinSign(msg []byte, key *ecdsa.PrivateKey) ([]byte, error)
EthZeppelinSign generate a OpenZeppelin compatible signature. The produced signature is 65-byte in the [R || S || V] format where V is 27 or 28.
func GenGnosisSafeTx ¶
func GenGnosisSafeTx(to, safe string, value int64, data hexutil.Bytes, chainID int64, nonce int64) (*core.GnosisSafeTx, []byte, error)
GenGnosisSafeTx returns a safe tx, and the tx hash to be used to generate signature. More info: https://docs.safe.global/sdk/protocol-kit/guides/signatures/transactions Since Gnosis 1.3.0, ChainID is a part of the EIP-712 domain.
func GenRewardMerkleTree ¶
func GetLeafAddresses ¶
Types ¶
This section is empty.