- Overview
- Features
- Technical Details
- 3.1 Contract Inheritance
- 3.2 Key Data Structures
- 3.3 Core Functionality
- 3.4 Calculations and Algorithms
- 3.5 Security Measures
- 3.6 Gas Optimization
- 3.7 Events
- Prerequisites
- Installation
- Usage
- Deployment
- Testing
- Contributing
- License
The Advanced PGP Key Server is a smart contract-based solution for managing PGP keys on the Ethereum blockchain. It provides a decentralized platform for key registration, attestation, and trust scoring, enhancing the security and reliability of PGP key management.
- PGP key registration with staking mechanism
- Key attestation system
- Trust scoring based on attestations and account activity
- Key revocation functionality
- Stake withdrawal after key revocation
- Trust decay mechanism to encourage active participation
- Admin functions for parameter adjustment
The contract inherits from:
ReentrancyGuard
: Prevents reentrancy attacksOwnable
: Provides basic access controlPausable
: Allows pausing contract functionality
Stores information about a registered PGP key:
publicKey
: The PGP public key stringregistrationTime
: Timestamp of key registrationisRevoked
: Boolean flag for key revocation statusstake
: Amount of ETH staked with the keyattestations
: Mapping of attestor addresses to Attestation structsattestors
: Array of attestor addresses
Represents an attestation made for a PGP key:
timestamp
: When the attestation was madeweight
: Importance of the attestationisRevoked
: Whether the attestation has been revoked
Holds various metrics used to calculate trust scores:
totalWeight
: Sum of all attestation weightsrecentActivityScore
: Based on recent attestationslongevityScore
: Based on account agediversityScore
: Based on unique attestorsreputationScore
: Overall reputation score
- Key Registration
- Attestations
- Revocations
- Trust Scoring
- Stake Management
- Admin Functions
Formula: weight = 50 - (attesterScore / 10)
- Total Weight
- Recent Activity Score
- Diversity Score
- Longevity Score
- Reputation Score
- Raw Score Calculation
- Score Capping
- Trust Decay
- Final Score Assignment
- Attestation Process
- Trust Score Update
- Revocation Handling
- Stake Management
- ReentrancyGuard for all state-changing functions
- Pausable functionality for emergency stops
- Access control for admin functions (Ownable)
- Limits the number of attestors processed in trust calculations (MAX_ATTESTORS_PER_UPDATE)
- Unique Attestor Tracking
- Selective Updates
- Key registration
- Attestations (made/revoked)
- Key revocation
- Trust score updates
- Admin parameter changes
Before you begin, ensure you have met the following requirements:
- Node.js (v14.0.0 or later)
- npm (v6.0.0 or later)
- An Ethereum wallet with test ETH (for deploying to testnets)
- Infura account (for deploying to public networks)
- Etherscan API key (for contract verification)
-
Clone the repository:
git clone https://github.com/your-username/advanced-pgp-key-server.git cd advanced-pgp-key-server
-
Install the dependencies:
npm install
-
Create a
.env
file in the root directory and add the following environment variables:MNEMONIC="your mnemonic phrase" INFURA_PROJECT_ID="your infura project id" ETHERSCAN_API_KEY="your etherscan api key"
To interact with the contract, you can use Hardhat tasks or write your own scripts. Here are some example commands:
-
Compile the contracts:
npm run compile
-
Run the tests:
npm run test
-
Deploy to local Hardhat network:
npm run deploy
The contract can be deployed to various Ethereum networks. Use the following commands for deployment:
-
Deploy to Sepolia testnet:
npm run deploy:sepolia
-
Deploy to Holesky testnet:
npm run deploy:holesky
-
Deploy to Ethereum mainnet:
npm run deploy:mainnet
Note: Make sure you have sufficient ETH in your wallet to cover the deployment gas costs.
The contract has been deployed to the Holesky testnet at the following address:
0x431F968abe3Bf65b5Ac6998513A89E9D5c80CDD1
Test suite contains 38 tests. Currently all of them functioning as expected. To run the test suite, execute:
npm run test
Contributions to the Advanced PGP Key Server project are welcome. Please follow these steps to contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature-name
) - Make your changes
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature-name
) - Create a new Pull Request
Please make sure to update tests as appropriate and adhere to the existing coding style.
This project is licensed under the MIT License. See the LICENSE
file for details.
For more information or support, please open an issue in the GitHub repository.