#identifier #keri #sai

said

Self-Addressing identifier library

3 releases

0.1.2 Aug 23, 2021
0.1.1 Aug 17, 2021
0.1.0 Aug 17, 2021

#542 in Cryptography

Download history 3/week @ 2022-03-03 7/week @ 2022-03-10 85/week @ 2022-03-17 10/week @ 2022-03-24 5/week @ 2022-03-31 3/week @ 2022-04-07 2/week @ 2022-04-14 5/week @ 2022-04-21 26/week @ 2022-04-28 39/week @ 2022-05-05 54/week @ 2022-05-12 16/week @ 2022-05-19 39/week @ 2022-05-26 33/week @ 2022-06-02 4/week @ 2022-06-09 7/week @ 2022-06-16

86 downloads per month
Used in oca-rust

Apache-2.0

12KB
239 lines

Self-Addressing Identifier

Self-Addressing Identifier (SAI) provides a compact text representation of digests of data. It supports multiple hash algorithms.

Self Addressing Identifier is base64 encoded hash of data, prepended with one or two letter prefix, called derivation code. Derivation code determines which hash algorithm was used to derive the digest.

derivation code digest type code length identifier length
E Blake3-256 Digest 1 44
F Blake2b-256 Digest 1 44
G Blake2s-256 Digest 1 44
H SHA3-256 Digest 1 44
I SHA2-256 Digest 1 44
0D Blake3-512 Digest 2 88
0E Blake2b-512 Digest 2 88
0F SHA3-512 Digest 2 88
0G SHA2-512 Digest 2 88

Usage

To derive Self Addressing Identifier, SelfAddressing enum can be used. It determines hashing algorithm used for Identifier derivation. Here are its possible values:

pub enum SelfAddressing {
    Blake3_256,
    Blake2B256(Vec<u8>),
    Blake2S256(Vec<u8>),
    SHA3_256,
    SHA2_256,
    Blake3_512,
    SHA3_512,
    Blake2B512,
    SHA2_512,
}

verify_bindings function checks if provided data matches digest encoded in Self Addressing Identifier.

Example

let data = "hello there";
let sai = SelfAddressing::Blake3_256.derive(data.as_bytes());

assert_eq!(format!("{}", sai), "E2bCqepXGid_9s1nSEyKk4kljbl3GULx5JjkFvIwJ8sk");
assert!(sai.verify_binding(data.as_bytes()));
assert!(!sai.verify_binding("wrong data".as_bytes()));

wasm

bindings/sai_wasm directory contains a project which allows to compile sai library to wasm.

Releasing new version

cargo-release is required

To release new version run cargo release

Due to release config it will bump version, create new git tag and push it to remote.

Dependencies

~3.5MB
~75K SLoC