make cargo publish work
This commit is contained in:
parent
a38845ef0b
commit
92f4319dbc
4 changed files with 170 additions and 9 deletions
|
|
@ -1,11 +1,15 @@
|
|||
[package]
|
||||
name = "sharenet-passport"
|
||||
version = "0.1.0"
|
||||
publish = ["sharenet-sh-forgejo"] # Set this to whichever Cargo registry you are publishing to
|
||||
edition = "2021"
|
||||
description = "Core library for Sharenet Passport creation and management"
|
||||
authors = ["Your Name <your.email@example.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["Continuist <continuist02@gmail.com>"]
|
||||
license = "CC-BY-NC-SA-4.0"
|
||||
repository = "https://git.sharenet.sh/your-org/sharenet-passport"
|
||||
readme = "README.md"
|
||||
keywords = ["cryptography", "identity", "passport", "sharenet"]
|
||||
categories = ["cryptography", "authentication"]
|
||||
|
||||
[dependencies]
|
||||
bip39 = "2.1"
|
||||
|
|
@ -31,7 +35,4 @@ alloc = [] # No-std with alloc support
|
|||
wasm = ["alloc"] # WASM target support
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.8"
|
||||
|
||||
[publish]
|
||||
registry = "sharenet"
|
||||
tempfile = "3.8"
|
||||
162
libs/sharenet-passport/README.md
Normal file
162
libs/sharenet-passport/README.md
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
# Sharenet Passport Library
|
||||
|
||||
A secure Rust library for creating and managing Sharenet Passport files (.spf) for decentralized identity management.
|
||||
|
||||
## Features
|
||||
|
||||
- **Secure Passport Creation**: Generate encrypted .spf files with BIP-39 mnemonic recovery phrases
|
||||
- **Ed25519 Key Generation**: Cryptographically secure key derivation and signing
|
||||
- **Recovery Support**: Import passports from recovery phrases or existing .spf files
|
||||
- **Export & Re-encrypt**: Export passports with new passwords
|
||||
- **Message Signing**: Sign messages using your passport's private key
|
||||
- **Security First**: Zeroize memory management and secure file encryption
|
||||
- **WASM Support**: Compatible with web applications via WebAssembly
|
||||
|
||||
## Installation
|
||||
|
||||
### From Private Registry
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
sharenet-passport = { version = "0.1.0", registry = "sharenet-sh-forgejo", features = ["std"] }
|
||||
```
|
||||
|
||||
### For WASM Projects
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
sharenet-passport = { version = "0.1.0", registry = "sharenet-sh-forgejo", features = ["wasm"] }
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Creating a New Passport
|
||||
|
||||
```rust
|
||||
use sharenet_passport::{
|
||||
application::use_cases::CreatePassportUseCase,
|
||||
infrastructure::{Bip39MnemonicGenerator, Ed25519KeyDeriver, XChaCha20FileEncryptor, FileSystemStorage},
|
||||
};
|
||||
|
||||
let use_case = CreatePassportUseCase::new(
|
||||
Bip39MnemonicGenerator,
|
||||
Ed25519KeyDeriver,
|
||||
XChaCha20FileEncryptor,
|
||||
FileSystemStorage,
|
||||
);
|
||||
|
||||
let (passport, recovery_phrase) = use_case.execute("your-password", "passport.spf")?;
|
||||
|
||||
println!("Public Key: {:?}", passport.public_key());
|
||||
println!("DID: {}", passport.did().as_str());
|
||||
println!("Recovery Phrase: {}", recovery_phrase.to_string());
|
||||
```
|
||||
|
||||
### Importing from Recovery Phrase
|
||||
|
||||
```rust
|
||||
use sharenet_passport::{
|
||||
application::use_cases::ImportFromRecoveryUseCase,
|
||||
infrastructure::{Bip39MnemonicGenerator, Ed25519KeyDeriver, XChaCha20FileEncryptor, FileSystemStorage},
|
||||
};
|
||||
|
||||
let use_case = ImportFromRecoveryUseCase::new(
|
||||
Bip39MnemonicGenerator,
|
||||
Ed25519KeyDeriver,
|
||||
XChaCha20FileEncryptor,
|
||||
FileSystemStorage,
|
||||
);
|
||||
|
||||
let recovery_words = vec!["word1".to_string(), "word2".to_string(), /* ... 24 words */];
|
||||
let passport = use_case.execute(&recovery_words, "new-password", "recovered-passport.spf")?;
|
||||
```
|
||||
|
||||
### Signing Messages
|
||||
|
||||
```rust
|
||||
use sharenet_passport::{
|
||||
application::use_cases::{ImportFromFileUseCase, SignCardUseCase},
|
||||
infrastructure::{XChaCha20FileEncryptor, FileSystemStorage},
|
||||
};
|
||||
|
||||
// Import passport from file
|
||||
let import_use_case = ImportFromFileUseCase::new(
|
||||
XChaCha20FileEncryptor,
|
||||
FileSystemStorage,
|
||||
);
|
||||
|
||||
let passport = import_use_case.execute("passport.spf", "password", None)?;
|
||||
|
||||
// Sign message
|
||||
let sign_use_case = SignCardUseCase::new();
|
||||
let signature = sign_use_case.execute(&passport, "Hello, Sharenet!")?;
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
Built with Clean Architecture principles:
|
||||
|
||||
- **Domain Layer**: Core entities (Passport, RecoveryPhrase, PublicKey, etc.) and traits
|
||||
- **Application Layer**: Use cases (CreatePassport, ImportFromRecovery, SignCard, etc.)
|
||||
- **Infrastructure Layer**: Crypto implementations, file storage
|
||||
|
||||
## Feature Flags
|
||||
|
||||
- `std` (default): Standard library support for CLI and server applications
|
||||
- `wasm`: WebAssembly support for web applications
|
||||
- `alloc`: No-std with allocator support
|
||||
|
||||
## Security Features
|
||||
|
||||
- **XChaCha20-Poly1305**: Authenticated encryption for file security
|
||||
- **HKDF-SHA256**: Key derivation from passwords
|
||||
- **Zeroize**: Secure memory wiping for sensitive data
|
||||
- **BIP-39**: Standard mnemonic generation and validation
|
||||
- **Ed25519**: Cryptographically secure signing
|
||||
|
||||
## File Format (.spf)
|
||||
|
||||
Sharenet Passport Files (.spf) are encrypted containers that store:
|
||||
|
||||
- **Encrypted Seed**: The master seed encrypted with XChaCha20-Poly1305
|
||||
- **Public Key**: Your Ed25519 public key
|
||||
- **DID**: Your Decentralized Identifier
|
||||
- **Metadata**: Creation timestamp, version, and encryption parameters
|
||||
|
||||
## Development
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
cargo test
|
||||
|
||||
# Test specific features
|
||||
cargo test --features std
|
||||
cargo test --features wasm
|
||||
```
|
||||
|
||||
### Building for WASM
|
||||
|
||||
```bash
|
||||
# Install wasm-pack if needed
|
||||
cargo install wasm-pack
|
||||
|
||||
# Build for web
|
||||
wasm-pack build --target web --features wasm
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
||||
|
||||
You are free to:
|
||||
- **Share** — copy and redistribute the material in any medium or format
|
||||
- **Adapt** — remix, transform, and build upon the material
|
||||
|
||||
Under the following terms:
|
||||
- **Attribution** — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
|
||||
- **NonCommercial** — You may not use the material for commercial purposes.
|
||||
- **ShareAlike** — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
|
||||
|
||||
To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::domain::entities::*;
|
||||
use crate::domain::traits::{MnemonicGenerator, KeyDeriver, FileEncryptor};
|
||||
use crate::{Bip39MnemonicGenerator, Ed25519KeyDeriver, XChaCha20FileEncryptor};
|
||||
|
|
@ -22,7 +21,7 @@ mod tests {
|
|||
let generator = Bip39MnemonicGenerator;
|
||||
|
||||
// This is a valid test mnemonic
|
||||
let valid_words = vec![
|
||||
let _valid_words = vec![
|
||||
"abandon".to_string(), "abandon".to_string(), "abandon".to_string(),
|
||||
"abandon".to_string(), "abandon".to_string(), "abandon".to_string(),
|
||||
"abandon".to_string(), "abandon".to_string(), "abandon".to_string(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use tempfile::NamedTempFile;
|
||||
use crate::domain::traits::FileStorage;
|
||||
use crate::{FileSystemStorage, PassportFile};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue