pub struct Provider {
    pub keypair: RsaKeyPair,
    pub sr: SystemRandom,
}
Expand description

Struct for for crypto methods.

Fields

keypair: RsaKeyPairsr: SystemRandom

Implementations

Reads a JsonWebKey from a PathBuf and stores it as a signature::RsaKeyPair in the keypair property of Provider for future use in signing and funding transactions.

Sync version of Provider::from_keypair_path.

Returns the full modulus of the stored keypair. Encoded as a Base64Url String, represents the associated network address. Also used in the calculation of transaction signatures.

Calculates the wallet address of the provided keypair according to addressing in documentation.

 let arweave = Arweave::from_keypair_path(
     PathBuf::from("tests/fixtures/arweave-key-7eV1qae4qVNqsNChg3Scdi-DpOLJPCogct4ixoq1WNg.json"),
     Url::from_str("http://url.com").unwrap()
 ).await?;
 let calc = arweave.crypto.wallet_address()?;
 let actual = String::from("7eV1qae4qVNqsNChg3Scdi-DpOLJPCogct4ixoq1WNg");
 assert_eq!(&calc.to_string(), &actual);

Verifies that a message was signed by the public key of the Provider.key keypair.

 let crypto = Provider::from_keypair_path(PathBuf::from("tests/fixtures/arweave-key-7eV1qae4qVNqsNChg3Scdi-DpOLJPCogct4ixoq1WNg.json")).await?;
 let message = String::from("hello, world");
 let rng = rand::SystemRandom::new();
 let signature = crypto.sign(&message.as_bytes())?;

 assert_eq!((), crypto.verify(&signature.as_ref(), &message.as_bytes())?);

Returns a SHA256 hash of the the concatenated SHA256 hashes of a vector of messages.

Calculates data root of transaction in accordance with implementation in arweave-js. DeepHashItem is a recursive Enum that allows the function to be applied to nested Vec<u8> of arbitrary depth.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more