Documentation Index
Fetch the complete documentation index at: https://mintlify.com/amark/gun/llms.txt
Use this file to discover all available pages before exploring further.
SEA: Security, Encryption, and Authorization
SEA is GUN’s cryptographic security layer that provides end-to-end encryption, digital signatures, and user authentication. It implements a complete security suite built on Web Crypto API standards.What is SEA?
SEA (Security, Encryption, and Authorization) is a polyfill/shim approach to adding cryptographic capabilities to GUN. It provides:- User Authentication: Create and authenticate users with key pairs
- End-to-End Encryption: AES-GCM encryption for private data
- Digital Signatures: ECDSA signatures to verify data authenticity
- Certificates: Grant permissions to other users
- Proof of Work: PBKDF2-based password hardening
Core Features
Cryptographic Standards
SEA uses industry-standard cryptographic algorithms:- ECDSA (P-256 curve): For signing and verifying data
- ECDH (P-256 curve): For deriving shared secrets
- AES-GCM (256-bit): For symmetric encryption
- PBKDF2 (SHA-256, 100,000 iterations): For key derivation
- SHA-256: For hashing
Key Pair Structure
SEA generates two types of key pairs for each user:Quick Start
HTTPS Requirement
Exceptions to HTTPS requirement:localhost127.x.x.xIP addressesfile://protocolblob:protocol
API Methods
SEA provides both user-level and utility methods:User Methods
user.create()- Create a new user accountuser.auth()- Authenticate a useruser.leave()- Log out the current user
Cryptographic Methods
SEA.pair()- Generate a new key pairSEA.sign()- Sign data with a private keySEA.verify()- Verify a signatureSEA.encrypt()- Encrypt dataSEA.decrypt()- Decrypt dataSEA.certify()- Create permission certificatesSEA.work()- Perform proof of work / hashing
Integration with GUN
SEA integrates seamlessly with GUN’s graph database:Architecture
SEA is implemented as a series of modules insea.js:
- Buffer/Array handling: Custom buffer implementation for encoding conversions
- Shim layer: Polyfills for Web Crypto API in Node.js and browsers
- Settings: Cryptographic algorithm configurations
- Core methods: Pair, sign, verify, encrypt, decrypt, certify, work
- User system: Authentication and session management
Security Considerations
Browser and Node.js Support
SEA works in both environments:- Browser: Uses native Web Crypto API
- Node.js: Uses
@peculiar/webcryptopolyfill and Node’scryptomodule
Next Steps
- Learn about User Authentication
- Understand Key Pair Generation
- Explore Encryption and Decryption
- Implement Digital Signatures