18 releases (stable)

4.2.0 Jan 19, 2024
3.1.0 Jan 1, 2023
3.0.3 Dec 6, 2022
3.0.2 Nov 29, 2022
0.1.0 Sep 23, 2021

#412 in Cryptography

Download history 4/week @ 2024-01-17 13/week @ 2024-02-14 66/week @ 2024-02-21 11/week @ 2024-02-28 8/week @ 2024-03-13

92 downloads per month
Used in 6 crates

MIT license

64KB
1.5K SLoC

Fides

Fides is a library for cryptographic primitives.

Author

Features

  • Digital Signature Algorithms
  • Hashing
  • Public Key Exchange
  • Data Structures like Bloom Filters & Radix Tree

Digital Signature Algorithms

ed25519

secret_key -> secret_key

public_key: secret_key -> public_key

sign: message, secret_key -> signature

verify: message, public_key, signature -> bool

Public Key Exchange

x25519

secret_key -> secret_key

public_key: secret_key -> public_key

shared_key: public_key, secret_key -> shared_secret

Data Structures

Bloom Filter

Radix Tree

Structs

RadixTree<K, V>: Represents the radix tree, generic over K for key and V for value.

  • nodes: HashMap storing the nodes of the tree, each identified by a 32-byte array.
  • parents: HashMap tracking the parent of each node.
  • root: 32-byte array representing the root node.

RadixNode<K, V>: Represents a single node within the RadixTree.

  • children: BTreeMap mapping keys to child node hashes.
  • key: Vec<K> representing the node's key.
  • value: Optional V holding the value associated with the key.

Methods

new() -> Self: Creates a new instance of RadixTree.

insert<I>(&mut self, key: I, value: V): Inserts a key-value pair into the tree.

rehash(&mut self, child_hash: &[u8; 32]): Updates the hash of a child node.

remove<I>(&mut self, key: I) -> Result<(), Box<dyn Error>>: Removes a key-value pair.

search<I>(&self, key: I) -> Option<&V>: Searches for a value by key.

split_node(&mut self, node_hash: [u8; 32], split_position: usize) -> Result<([u8; 32], [u8; 32]), Box<dyn Error>>: Splits a node at a specified position.

Traits

IntoBytes: Provides functionality to serialize RadixTree and RadixNode into bytes.

  • For RadixNode<K, V>:

into_bytes(&self) -> Vec<u8>: Serializes the RadixNode into a byte vector. This includes serializing the children, key, and value fields.

  • For RadixTree<K, V>:

into_bytes(&self) -> Vec<u8>: Serializes the entire RadixTree into a byte vector. This process involves serializing the root and each node in nodes (using RadixNode's into_bytes method).

Future

  • 🎲 Random Number Generator
  • 🔒 Encryption
  • 🏗 Accumulation
  • 📜 Commitment Schemes
  • 😎 Zero-knowledge Proof Schemes
  • ⏲ Verifiable Delay Function
  • 🔢 Fully Homomorphic Encryption

License

MIT License

Copyright Stelar Labs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Dependencies

~6MB
~116K SLoC