[][src]Trait tweetnacl_rs::TweetNacl

pub trait TweetNacl {
    fn gen(self) -> ([u8; 32], [u8; 64]);
fn sign(self, _m: String) -> Vec<u8>;
fn verify(self, _m: String, _sm: &Vec<u8>) -> bool; }

TweetNacl Trait for slice.

Usage

use tweetnacl_rs::TweetNacl;
 
fn main() {
    let (pk, sk) = [0; 32].gen();
    println!("public key: {:?}", pk);
    println!("secret key: {:?}", sk.to_vec());
 
    let sm = sk.sign("hello, world".to_string());
    println!("signed message: {:?}", sm.to_vec());
 
    let ret = pk.verify("hello, world".to_string(), &sm);
    assert_eq!(ret, true);
}

Required methods

fn gen(self) -> ([u8; 32], [u8; 64])

fn sign(self, _m: String) -> Vec<u8>

fn verify(self, _m: String, _sm: &Vec<u8>) -> bool

Loading content...

Implementations on Foreign Types

impl<'_> TweetNacl for &'_ [u8][src]

fn gen(self) -> ([u8; 32], [u8; 64])[src]

Generate a keypair from seed.

Panics

Seed should be [u8; 32].

fn sign(self, _m: String) -> Vec<u8>[src]

Sign a message using secret key.

fn verify(self, _m: String, _sm: &Vec<u8>) -> bool[src]

Verify signature.

Panics

  • PublicKey should be [u8; 32].
  • Signed Message's length minus Message's length shoule be 64.
Loading content...

Implementors

Loading content...