Explcit compress/decompress test
This commit is contained in:
parent
8aaebe8799
commit
990f0004e5
15
src/lib.rs
15
src/lib.rs
|
@ -130,6 +130,7 @@ impl FuzzyTag {
|
|||
/// let tag = public_key.generate_tag();
|
||||
/// let compressed_tag = tag.compress();
|
||||
/// let decompressed_tag = FuzzyTag::decompress(&compressed_tag).unwrap();
|
||||
/// assert_eq!(tag, decompressed_tag);
|
||||
/// ```
|
||||
pub fn decompress(bytes: &Vec<u8>) -> Option<FuzzyTag> {
|
||||
if bytes.len() > 64 {
|
||||
|
@ -480,6 +481,20 @@ mod tests {
|
|||
use curve25519_dalek::ristretto::RistrettoPoint;
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
|
||||
#[test]
|
||||
fn test_compression() {
|
||||
let gamma = 24;
|
||||
let secret_key = FuzzySecretKey::generate(gamma);
|
||||
let public_key = secret_key.public_key();
|
||||
|
||||
// Give public key to a another party...
|
||||
// and then they can do...
|
||||
let tag = public_key.generate_tag();
|
||||
let compressed_tag = tag.compress();
|
||||
let decompressed_tag = FuzzyTag::decompress(&compressed_tag).unwrap();
|
||||
assert_eq!(tag, decompressed_tag);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
// We support up to gamma=64 when deserializing..
|
||||
|
|
Loading…
Reference in New Issue