Objective: indy-crypto
exposes the low level API for generating and reconstructing secrets. indy-sdk
uses the underlying indy-crypto
and exposes an API to shard a JSON message, store the shards and reconstitute the secret.
shard_secret(secret: bytes, m: u8, n: u8, sign_shares: Option<bool>) -> Result<Vec<Share>, IndyCryptoError>
.
Splits the bytes of the secretsecret
inn
different shares andm-of-n
shares are required to reconstitute the secret.sign_shares
if provided, all shards are signed.recover_secret(shards: Vec<Share>, verify_signatures: Option<bool>) -> Result<Vec<u8>, IndyCryptoError>
.
Recover the secret from the givenshards
.verify_signatures
if given verifies the signatures.
shard_JSON(msg: String, m: u8, n: u8, sign_shares: Option<bool>) -> Result<Vec<String>, IndyError>
Takes the message as a JSON string and serialises it to bytes and passes it toshard_secret
ofindy-crypto
. The serialisation has to be deterministic, i.e the same JSON should always serialise to same bytes everytime. The resultingShare
given byindy-crypto
is converted to JSON before returning.shard_JSON_with_wallet_data(wallet_handle: i32, msg: String, wallet_keys:Vec<&str>, m: u8, n: u8, sign_shares: Option<bool>) -> Result<Vec<String>, IndyError>
Takes the message as a JSON string, updates the JSON with key-values from wallet given by handlewallet_handle
, keys present in the vectorwallet_keys
and passes the resulting JSON toshard_JSON
.recover_secret(shards: Vec<String>, verify_signatures: Option<bool>) -> Result<String, IndyError>
Takes a collection of shards each encoded as JSON, deserialises them intoShare
s and passes them torecover_secret
fromindy-crypto
. It converts the resulting secret back to JSON before returning it.shard_JSON_and_store_shards(wallet_handle: i32, msg: String, m: u8, n: u8, sign_shares: Option<bool>) -> Result<String, IndyError>
Shards the given JSON usingshard_JSON
and store shards as a JSON array (each shard is an object in itself) in the wallet given bywallet_handle
. Returns the wallet key used to store the shards.