Skip to content

Commit

Permalink
updates readme
Browse files Browse the repository at this point in the history
  • Loading branch information
seanwatters committed Feb 7, 2024
1 parent 3fa9358 commit 8f56d09
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ license = "MIT"
name = "rgp"
readme = "README.md"
repository = "https://github.com/ordinarylabs/RGP"
version = "0.1.3"
version = "0.1.4"

[dependencies]
chacha20 = "0.9.1"
Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,32 @@
## Usage

```rust
let (our_priv_key, our_pub_key) = rgp::generate_exchange_keys();
let (fingerprint, verifying_key) = rgp::signature::generate_fingerprint();

let (our_priv_key, our_pub_key) = rgp::generate_exchange_keys();
let mut pub_keys = vec![our_pub_key];

// 8mb
let content = vec![0u8; 8_000_000];

// 20,000 recipients
for _ in 0..20_000 {
let (_, pub_key) = rgp::generate_exchange_keys();
pub_keys.push(pub_key)
}

let mut encrypted_content =
rgp::content::encrypt(fingerprint, content.clone(), &pub_keys).unwrap();
// 8mb
let content = vec![0u8; 8_000_000];

let mut encrypted_content = rgp::content::encrypt(
fingerprint,
content.clone(),
&pub_keys
)
.unwrap();

rgp::content::extract_content_for_key_position(&mut encrypted_content, 0).unwrap();
rgp::content::extract_content_for_key_position(
&mut encrypted_content,
0
)
.unwrap();

let decrypted_content = rgp::content::decrypt(
Some(&verifying_key),
Expand All @@ -45,6 +53,7 @@ assert_eq!(decrypted_content, content);
1. Generate one-time and ephemeral components
- **one-time public key**
- **ephemeral private key**
- **nonce**
- **one-time content key**
2. Sign plaintext to generate **content signature**
3. Encrypt plaintext and **content signature** with **one-time content key**
Expand All @@ -61,14 +70,14 @@ assert_eq!(decrypted_content, content);

## Encrypted Format

- nonce = 24 bytes
- one-time public key = 32 bytes
- **nonce** = 24 bytes
- **one-time public key** = 32 bytes
- keys count (2-9 bytes)
- int size = 1 byte (1 for u8 | 2 for u16 | 4 for u32 | 8 for u64)
- big endian int = 1-8 bytes
- encrypted keys = pub_keys.len() * 32 bytes
- encrypted content = content.len()
- inner signature = 64 bytes (encrypted along with the content to preserve deniability)
- **signature** = 64 bytes (encrypted along with the content to preserve deniability)
- Poly1305 MAC = 16 bytes

## License
Expand Down

0 comments on commit 8f56d09

Please sign in to comment.