[][src]Trait secp256kfun::marker::Secrecy

pub trait Secrecy: Default + Clone + PartialEq + Copy { }

A marker trait implemented by Secret and Public.

Scalars and Points both have a Secrecy type parameter which must be either Secret or Public. At a high level these indicate:

  • Secret: This value must be kept secret from parties I interact with.
  • Public: This value is known or it would not harm my security if this value is known to all parties I interact with.

Note this consideration is only important if you do operations on the value during an interaction with a party. So if you would like to keep scalar x secret from party C but you only do operations on x while interacting with B (who perhaps, already knows it), then, in theory, x can be marked Public. However it is up to you to make sure these conditions hold so the prudent thing to do is make sure that anything that might be secret in some circumstance is marked Secret.

Scalars are by default Secret and Points are by default Public. In order to change the default you must mark it.

use secp256kfun::{marker::*, Point, Scalar};
let public_scalar = Scalar::random(&mut rand::thread_rng()).mark::<Public>();
let secret_point = Point::random(&mut rand::thread_rng()).mark::<Secret>();

The choice between a variable time or constant time algorithm is done through specialization.

use secp256kfun::{g, marker::*, Point, Scalar, G};
let x = Scalar::random(&mut rand::thread_rng());
let H = Point::random(&mut rand::thread_rng());
let X = g!(x * H); // This is constant time because x is secret
let x = x.mark::<Public>();
let X = g!(x * H); // This will run faster (in variable time)

Implementors

impl Secrecy for Public[src]

impl Secrecy for Secret[src]

Loading content...