Documentation
¶
Index ¶
- Constants
- Variables
- func AuthorizeTransfer(name, newOwnerPubkey string, ownerSigner signer.I) (prevSig string, timestamp time.Time, err error)
- func CanRegister(nameState *NameState, proposerPubkey string) error
- func CheckCertificateExpiry(cert *Certificate) (time.Duration, error)
- func CreateCertificateWithWitnesses(req *CertificateRequest, witnesses []WitnessSignature, algorithm, usage string, ...) (*event.E, error)
- func CreateChallengeProof(challenge, name, certPubkey string, validUntil time.Time, signer signer.I) (string, error)
- func CreateChallengeProofMessage(challenge, name, certPubkey string, validUntil time.Time) []byte
- func CreateChallengeTXTRecord(name, challenge string, ttl int, signer signer.I) (*event.E, error)
- func CreateTransferAuthMessage(name, newOwner string, timestamp time.Time) []byte
- func CreateTransferProposal(name string, prevOwnerSigner, newOwnerSigner signer.I) (*event.E, error)
- func CreateTransferProposalWithAuth(name, prevOwnerPubkey, prevSig string, newOwnerSigner signer.I) (*event.E, error)
- func CreateWitnessMessage(certPubkey, name string, validFrom, validUntil time.Time, challenge string) []byte
- func ExtractChallengeFromTXTRecord(txtValue string) (string, error)
- func FormatChallengeProofString(challenge, name, certPubkey string, validUntil time.Time) string
- func FormatTransferAuthString(name, newOwner string, timestamp time.Time) string
- func FormatWitnessString(certPubkey, name string, validFrom, validUntil time.Time, challenge string) string
- func GenerateChallenge() (string, error)
- func GetParentDomain(name string) string
- func IsExpired(expiration time.Time) bool
- func IsInRenewalWindow(expiration time.Time) bool
- func IsTLD(name string) bool
- func NewAttestation(proposalID, decision string, weight int, reason, serviceURL string, ...) (*event.E, error)
- func NewCertificate(name, certPubkey string, validFrom, validUntil time.Time, ...) (*event.E, error)
- func NewNameRecord(name, recordType, value string, ttl int, signer signer.I) (*event.E, error)
- func NewNameRecordWithPriority(name, recordType, value string, ttl, priority int, signer signer.I) (*event.E, error)
- func NewNameState(name, owner string, registeredAt time.Time, proposalID string, ...) (*event.E, error)
- func NewRegistrationProposal(name, action string, signer signer.I) (*event.E, error)
- func NewRegistrationProposalWithTransfer(name, prevOwner, prevSig string, signer signer.I) (*event.E, error)
- func NewSRVRecord(name, value string, ttl, priority, weight, port int, signer signer.I) (*event.E, error)
- func NewTrustGraphEvent(entries []TrustEntry, signer signer.I) (*event.E, error)
- func NewWitnessService(endpoint string, challenges []string, maxValidity, fee int, ...) (*event.E, error)
- func NormalizeName(name string) string
- func ParseTimestampFromProposal(proposalTime time.Time) time.Time
- func ShouldRenewCertificate(cert *Certificate) bool
- func SignAttestation(ev *event.E, s signer.I) error
- func SignCertificate(ev *event.E, s signer.I) error
- func SignChallengeProof(challenge, name, certPubkey string, validUntil time.Time, s signer.I) (string, error)
- func SignNameRecord(ev *event.E, s signer.I) error
- func SignNameState(ev *event.E, s signer.I) error
- func SignProposal(ev *event.E, s signer.I) error
- func SignTransferAuth(name, newOwner string, timestamp time.Time, s signer.I) (string, error)
- func SignTrustGraph(ev *event.E, s signer.I) error
- func SignWitnessMessage(certPubkey, name string, validFrom, validUntil time.Time, challenge string, ...) (string, error)
- func SignWitnessService(ev *event.E, s signer.I) error
- func ValidateIPv4(ip string) error
- func ValidateIPv6(ip string) error
- func ValidateName(name string) error
- func ValidatePort(port int) error
- func ValidatePriority(priority int) error
- func ValidateRecordLimit(recordType string, currentCount int) error
- func ValidateRecordValue(recordType, value string) error
- func ValidateTransferProposal(proposal *RegistrationProposal, currentOwner string) error
- func ValidateTrustScore(score float64) error
- func ValidateWeight(weight int) error
- func VerifyAttestationExpiration(attestation *Attestation) error
- func VerifyCertificate(cert *Certificate, nameState *NameState, trustedWitnesses []string) error
- func VerifyCertificateValidity(cert *Certificate) error
- func VerifyChallengeProof(challenge, name, certPubkey, owner string, validUntil time.Time, sigHex string) (bool, error)
- func VerifyChallengeTXTRecord(record *NameRecord, expectedChallenge string, nameOwner string) error
- func VerifyEvent(ev *event.E) error
- func VerifyNameOwnership(nameState *NameState, record *NameRecord) error
- func VerifyNameStateExpiration(nameState *NameState) error
- func VerifyProposalExpiration(proposal *RegistrationProposal) error
- func VerifySubdomainAuthority(name string, proposerPubkey string, parentNameState *NameState) error
- func VerifyTransferAuth(name, newOwner, prevOwner string, timestamp time.Time, sigHex string) (bool, error)
- func VerifyTransferProposalSignature(proposal *RegistrationProposal) error
- func VerifyTrustGraphExpiration(trustGraph *TrustGraphEvent) error
- func VerifyWitnessSignature(certPubkey, name string, validFrom, validUntil time.Time, ...) (bool, error)
- type Attestation
- type Certificate
- func IssueCertificate(name, certPubkey string, validityDuration time.Duration, ownerSigner signer.I, ...) (*Certificate, error)
- func ParseCertificate(ev *event.E) (*Certificate, error)
- func RenewCertificate(oldCert *Certificate, newValidityDuration time.Duration, ownerSigner signer.I, ...) (*Certificate, error)
- type CertificateRequest
- type ChallengeProofMessage
- type ConsensusEngine
- func (ce *ConsensusEngine) ComputeConsensus(proposals []*RegistrationProposal, attestations []*Attestation) (*ConsensusResult, error)
- func (ce *ConsensusEngine) CreateNameState(result *ConsensusResult, registryPubkey []byte) (*NameState, error)
- func (ce *ConsensusEngine) ProcessProposalBatch(proposals []*RegistrationProposal, attestations []*Attestation) ([]*ConsensusResult, error)
- func (ce *ConsensusEngine) QueryNameState(name string) (*NameState, error)
- func (ce *ConsensusEngine) ScoreProposal(proposal *RegistrationProposal, attestations []*Attestation) (float64, map[string]float64)
- func (ce *ConsensusEngine) ValidateProposal(proposal *RegistrationProposal) error
- func (ce *ConsensusEngine) ValidateTransfer(proposal *RegistrationProposal) error
- type ConsensusResult
- type NameRecord
- type NameState
- type ProposalScore
- type ProposalState
- type RegistrationProposal
- type RegistryConfig
- type RegistryMetrics
- type RegistryService
- func (rs *RegistryService) GetMetrics() *RegistryMetrics
- func (rs *RegistryService) GetTrustGraph() *TrustGraph
- func (rs *RegistryService) HandleEvent(ev *event.E) error
- func (rs *RegistryService) OnProposalReceived(proposal *RegistrationProposal) error
- func (rs *RegistryService) QueryNameOwnership(name string) (*NameState, error)
- func (rs *RegistryService) Start() error
- func (rs *RegistryService) Stop() error
- func (rs *RegistryService) ValidateProposal(proposal *RegistrationProposal) error
- type TransferAuthorization
- type TrustEntry
- type TrustGraph
- func (tg *TrustGraph) AddEntry(entry TrustEntry) error
- func (tg *TrustGraph) AddTrustGraph(graph *TrustGraph) error
- func (tg *TrustGraph) CalculateTrustMetrics() *TrustMetrics
- func (tg *TrustGraph) ExportTrustGraph() *TrustGraphEvent
- func (tg *TrustGraph) GetAllEntries() map[string][]TrustEntry
- func (tg *TrustGraph) GetDirectTrust() []TrustEntry
- func (tg *TrustGraph) GetInheritedTrust(fromPubkey, toPubkey string) (float64, []string)
- func (tg *TrustGraph) GetTrustLevel(pubkey []byte) float64
- func (tg *TrustGraph) GetTrustedServices() []string
- func (tg *TrustGraph) RemoveEntry(pubkey string)
- func (tg *TrustGraph) UpdateEntry(pubkey string, newScore float64) error
- type TrustGraphEvent
- type TrustMetrics
- type WitnessMessage
- type WitnessService
- type WitnessSignature
Constants ¶
const ( KindRegistrationProposal = 30100 // Parameterized replaceable KindAttestation = 20100 // Ephemeral KindTrustGraph = 30101 // Parameterized replaceable KindNameState = 30102 // Parameterized replaceable KindNameRecords = 30103 // Parameterized replaceable KindCertificate = 30104 // Parameterized replaceable KindWitnessService = 30105 // Parameterized replaceable )
Event kind constants as defined in the NIP
const ( ActionRegister = "register" ActionTransfer = "transfer" )
Action types for registration proposals
const ( DecisionApprove = "approve" DecisionReject = "reject" DecisionAbstain = "abstain" )
Decision types for attestations
const ( RecordTypeA = "A" RecordTypeAAAA = "AAAA" RecordTypeCNAME = "CNAME" RecordTypeMX = "MX" RecordTypeTXT = "TXT" RecordTypeNS = "NS" RecordTypeSRV = "SRV" )
DNS record types
const ( ProposalExpiry = 5 * time.Minute // Proposals expire after 5 minutes AttestationExpiry = 3 * time.Minute // Attestations expire after 3 minutes TrustGraphExpiry = 30 * 24 * time.Hour // Trust graphs expire after 30 days NameRegistrationPeriod = 365 * 24 * time.Hour // Names expire after 1 year PreferentialRenewalDays = 30 // Final 30 days before expiration CertificateValidity = 90 * 24 * time.Hour // Recommended certificate validity WitnessServiceExpiry = 180 * 24 * time.Hour // Witness service info expires after 180 days )
Time constants
Variables ¶
var ( ErrInvalidName = errors.New("invalid name format") ErrNameTooLong = errors.New("name exceeds 253 characters") ErrLabelTooLong = errors.New("label exceeds 63 characters") ErrLabelEmpty = errors.New("label is empty") ErrInvalidCharacter = errors.New("invalid character in name") ErrInvalidHyphen = errors.New("label cannot start or end with hyphen") ErrAllNumericLabel = errors.New("label cannot be all numeric") ErrInvalidRecordValue = errors.New("invalid record value") ErrRecordLimitExceeded = errors.New("record limit exceeded") ErrNotOwner = errors.New("not the name owner") ErrNameExpired = errors.New("name registration expired") ErrInRenewalWindow = errors.New("name is in renewal window") ErrNotRenewalWindow = errors.New("not in renewal window") )
var RecordLimits = map[string]int{ RecordTypeA: 5, RecordTypeAAAA: 5, RecordTypeCNAME: 1, RecordTypeMX: 5, RecordTypeTXT: 10, RecordTypeNS: 5, RecordTypeSRV: 10, }
RecordLimits defines per-type record limits
Functions ¶
func AuthorizeTransfer ¶
func AuthorizeTransfer(name, newOwnerPubkey string, ownerSigner signer.I) (prevSig string, timestamp time.Time, err error)
AuthorizeTransfer creates a transfer authorization signature This is meant to be used by the current owner to authorize a transfer to a new owner
func CanRegister ¶
CanRegister checks if a name can be registered based on its state and expiration
func CheckCertificateExpiry ¶
func CheckCertificateExpiry(cert *Certificate) (time.Duration, error)
CheckCertificateExpiry returns the time until expiration, or error if expired
func CreateCertificateWithWitnesses ¶
func CreateCertificateWithWitnesses(req *CertificateRequest, witnesses []WitnessSignature, algorithm, usage string, ownerSigner signer.I) (*event.E, error)
CreateCertificateWithWitnesses creates a complete certificate event with witness signatures
func CreateChallengeProof ¶
func CreateChallengeProof(challenge, name, certPubkey string, validUntil time.Time, signer signer.I) (string, error)
CreateChallengeProof creates a challenge proof signature
func CreateChallengeProofMessage ¶
CreateChallengeProofMessage constructs the challenge proof message This is used for verification
func CreateChallengeTXTRecord ¶
CreateChallengeTXTRecord creates a TXT record event for challenge-response verification
func CreateTransferAuthMessage ¶
CreateTransferAuthMessage constructs the transfer authorization message This is used for verification
func CreateTransferProposal ¶
func CreateTransferProposal(name string, prevOwnerSigner, newOwnerSigner signer.I) (*event.E, error)
CreateTransferProposal creates a complete transfer proposal with authorization from previous owner
func CreateTransferProposalWithAuth ¶
func CreateTransferProposalWithAuth(name, prevOwnerPubkey, prevSig string, newOwnerSigner signer.I) (*event.E, error)
CreateTransferProposalWithAuth creates a transfer proposal using a pre-existing authorization This is useful when the previous owner has already provided their signature
func CreateWitnessMessage ¶
func CreateWitnessMessage(certPubkey, name string, validFrom, validUntil time.Time, challenge string) []byte
CreateWitnessMessage constructs the witness message This is used for verification
func ExtractChallengeFromTXTRecord ¶
ExtractChallengeFromTXTRecord extracts the challenge token from a TXT record value
func FormatChallengeProofString ¶
FormatChallengeProofString formats the challenge proof message for display/debugging
func FormatTransferAuthString ¶
FormatTransferAuthString formats the transfer auth message for display/debugging
func FormatWitnessString ¶
func FormatWitnessString(certPubkey, name string, validFrom, validUntil time.Time, challenge string) string
FormatWitnessString formats the witness message for display/debugging
func GenerateChallenge ¶
GenerateChallenge generates a random 32-byte challenge token
func GetParentDomain ¶
GetParentDomain returns the parent domain of a name e.g., "www.example.com" -> "example.com", "example.com" -> "com", "com" -> ""
func IsExpired ¶
IsExpired checks if a time-based expiration has passed
func IsInRenewalWindow ¶
IsInRenewalWindow checks if the current time is within the preferential renewal window (final 30 days before expiration)
func IsTLD ¶
IsTLD returns true if the name is a top-level domain (single label)
func NewAttestation ¶
func NewAttestation(proposalID, decision string, weight int, reason, serviceURL string, signer signer.I) (*event.E, error)
NewAttestation creates a new attestation event (kind 20100)
func NewCertificate ¶
func NewCertificate(name, certPubkey string, validFrom, validUntil time.Time, challenge, challengeProof string, witnesses []WitnessSignature, algorithm, usage string, signer signer.I) (*event.E, error)
NewCertificate creates a new certificate event (kind 30104)
func NewNameRecord ¶
NewNameRecord creates a new name record event (kind 30103)
func NewNameRecordWithPriority ¶
func NewNameRecordWithPriority(name, recordType, value string, ttl, priority int, signer signer.I) (*event.E, error)
NewNameRecordWithPriority creates a name record with priority (for MX, SRV)
func NewNameState ¶
func NewNameState(name, owner string, registeredAt time.Time, proposalID string, attestations int, confidence float64, signer signer.I) (*event.E, error)
NewNameState creates a new name state event (kind 30102)
func NewRegistrationProposal ¶
NewRegistrationProposal creates a new registration proposal event (kind 30100)
func NewRegistrationProposalWithTransfer ¶
func NewRegistrationProposalWithTransfer(name, prevOwner, prevSig string, signer signer.I) (*event.E, error)
NewRegistrationProposalWithTransfer creates a transfer proposal with previous owner signature
func NewSRVRecord ¶
func NewSRVRecord(name, value string, ttl, priority, weight, port int, signer signer.I) (*event.E, error)
NewSRVRecord creates an SRV record with all required fields
func NewTrustGraphEvent ¶ added in v0.29.14
NewTrustGraphEvent creates a new trust graph event (kind 30101)
func NewWitnessService ¶
func NewWitnessService(endpoint string, challenges []string, maxValidity, fee int, reputationID, description, contact string, signer signer.I) (*event.E, error)
NewWitnessService creates a new witness service info event (kind 30105)
func NormalizeName ¶
NormalizeName converts a name to lowercase
func ParseTimestampFromProposal ¶
ParseTimestampFromProposal extracts the timestamp from a transfer authorization message Used for verification when the timestamp is embedded in the signature
func ShouldRenewCertificate ¶
func ShouldRenewCertificate(cert *Certificate) bool
ShouldRenewCertificate checks if a certificate should be renewed (< 30 days until expiry)
func SignAttestation ¶
SignAttestation signs an attestation event
func SignCertificate ¶
SignCertificate signs a certificate event
func SignChallengeProof ¶
func SignChallengeProof(challenge, name, certPubkey string, validUntil time.Time, s signer.I) (string, error)
SignChallengeProof creates a signature for certificate challenge proof Message format: challenge||name||cert_pubkey||valid_until
func SignNameRecord ¶
SignNameRecord signs a name record event
func SignNameState ¶
SignNameState signs a name state event
func SignProposal ¶
SignProposal signs a registration proposal event
func SignTransferAuth ¶
SignTransferAuth creates a signature for transfer authorization Message format: transfer:<name>:<new_owner_pubkey>:<timestamp>
func SignTrustGraph ¶
SignTrustGraph signs a trust graph event
func SignWitnessMessage ¶
func SignWitnessMessage(certPubkey, name string, validFrom, validUntil time.Time, challenge string, s signer.I) (string, error)
SignWitnessMessage creates a witness signature for a certificate Message format: cert_pubkey||name||valid_from||valid_until||challenge
func SignWitnessService ¶
SignWitnessService signs a witness service event
func ValidateIPv4 ¶
ValidateIPv4 validates an IPv4 address format
func ValidateIPv6 ¶
ValidateIPv6 validates an IPv6 address format (simplified check)
func ValidateName ¶
ValidateName validates a name according to DNS naming rules
func ValidatePriority ¶
ValidatePriority validates priority value (0-65535)
func ValidateRecordLimit ¶
ValidateRecordLimit checks if adding a record would exceed type limits
func ValidateRecordValue ¶
ValidateRecordValue validates a record value based on its type
func ValidateTransferProposal ¶
func ValidateTransferProposal(proposal *RegistrationProposal, currentOwner string) error
ValidateTransferProposal validates a transfer proposal against the current owner
func ValidateTrustScore ¶
ValidateTrustScore validates trust score (0.0-1.0)
func ValidateWeight ¶
ValidateWeight validates weight value (0-65535)
func VerifyAttestationExpiration ¶
func VerifyAttestationExpiration(attestation *Attestation) error
VerifyAttestationExpiration checks if an attestation has expired
func VerifyCertificate ¶
func VerifyCertificate(cert *Certificate, nameState *NameState, trustedWitnesses []string) error
VerifyCertificate performs complete certificate verification
func VerifyCertificateValidity ¶
func VerifyCertificateValidity(cert *Certificate) error
VerifyCertificateValidity checks if a certificate is currently valid
func VerifyChallengeProof ¶
func VerifyChallengeProof(challenge, name, certPubkey, owner string, validUntil time.Time, sigHex string) (bool, error)
VerifyChallengeProof verifies a certificate challenge proof signature
func VerifyChallengeTXTRecord ¶
func VerifyChallengeTXTRecord(record *NameRecord, expectedChallenge string, nameOwner string) error
VerifyChallengeTXTRecord verifies that a TXT record contains the expected challenge
func VerifyEvent ¶
VerifyEvent verifies the signature of a Nostr event
func VerifyNameOwnership ¶
func VerifyNameOwnership(nameState *NameState, record *NameRecord) error
VerifyNameOwnership checks if a record's owner matches the name state owner
func VerifyNameStateExpiration ¶
VerifyNameStateExpiration checks if a name state has expired
func VerifyProposalExpiration ¶
func VerifyProposalExpiration(proposal *RegistrationProposal) error
VerifyProposalExpiration checks if a proposal has expired
func VerifySubdomainAuthority ¶
VerifySubdomainAuthority checks if the proposer owns the parent domain
func VerifyTransferAuth ¶
func VerifyTransferAuth(name, newOwner, prevOwner string, timestamp time.Time, sigHex string) (bool, error)
VerifyTransferAuth verifies a transfer authorization signature
func VerifyTransferProposalSignature ¶
func VerifyTransferProposalSignature(proposal *RegistrationProposal) error
VerifyTransferProposalSignature verifies both the event signature and transfer authorization
func VerifyTrustGraphExpiration ¶
func VerifyTrustGraphExpiration(trustGraph *TrustGraphEvent) error
VerifyTrustGraphExpiration checks if a trust graph has expired
Types ¶
type Attestation ¶
type Attestation struct {
Event *event.E
ProposalID string // Event ID of the proposal being attested
Decision string // "approve", "reject", or "abstain"
Weight int // Stake/confidence weight (default 100)
Reason string // Human-readable justification
ServiceURL string // Registry service endpoint
Expiration time.Time
}
Attestation represents a kind 20100 event
func ParseAttestation ¶
func ParseAttestation(ev *event.E) (*Attestation, error)
ParseAttestation parses a kind 20100 event into an Attestation
type Certificate ¶
type Certificate struct {
Event *event.E
Name string
CertPubkey string // Public key for the service
ValidFrom time.Time
ValidUntil time.Time
Challenge string // Challenge token for ownership proof
ChallengeProof string // Signature over challenge
Witnesses []WitnessSignature
Algorithm string // e.g., "secp256k1-schnorr"
Usage string // e.g., "tls-replacement"
}
Certificate represents a kind 30104 event
func IssueCertificate ¶
func IssueCertificate(name, certPubkey string, validityDuration time.Duration, ownerSigner signer.I, witnessSigners []signer.I) (*Certificate, error)
IssueCertificate is a helper that goes through the full certificate issuance process This would typically be used by a name owner to request a certificate
func ParseCertificate ¶
func ParseCertificate(ev *event.E) (*Certificate, error)
ParseCertificate parses a kind 30104 event into a Certificate
func RenewCertificate ¶
func RenewCertificate(oldCert *Certificate, newValidityDuration time.Duration, ownerSigner signer.I, witnessSigners []signer.I) (*Certificate, error)
RenewCertificate creates a renewed certificate with a new validity period
type CertificateRequest ¶
type CertificateRequest struct {
Name string
CertPubkey string
ValidFrom time.Time
ValidUntil time.Time
Challenge string
ChallengeProof string
}
PrepareCertificateRequest prepares all the data needed for a certificate request
type ChallengeProofMessage ¶
type ChallengeProofMessage struct {
Challenge string
Name string
CertPubkey string
ValidUntil time.Time
}
ChallengeProofMessage represents the message signed for certificate challenge proof
type ConsensusEngine ¶ added in v0.29.14
type ConsensusEngine struct {
// contains filtered or unexported fields
}
ConsensusEngine handles the consensus algorithm for name registrations
func NewConsensusEngine ¶ added in v0.29.14
func NewConsensusEngine(db database.Database, trustGraph *TrustGraph) *ConsensusEngine
NewConsensusEngine creates a new consensus engine
func (*ConsensusEngine) ComputeConsensus ¶ added in v0.29.14
func (ce *ConsensusEngine) ComputeConsensus(proposals []*RegistrationProposal, attestations []*Attestation) (*ConsensusResult, error)
ComputeConsensus computes consensus for a set of competing proposals
func (*ConsensusEngine) CreateNameState ¶ added in v0.29.14
func (ce *ConsensusEngine) CreateNameState(result *ConsensusResult, registryPubkey []byte) (*NameState, error)
CreateNameState creates a name state event from consensus result
func (*ConsensusEngine) ProcessProposalBatch ¶ added in v0.29.14
func (ce *ConsensusEngine) ProcessProposalBatch(proposals []*RegistrationProposal, attestations []*Attestation) ([]*ConsensusResult, error)
ProcessProposalBatch processes a batch of proposals and returns consensus results
func (*ConsensusEngine) QueryNameState ¶ added in v0.29.14
func (ce *ConsensusEngine) QueryNameState(name string) (*NameState, error)
QueryNameState queries the current name state from the database
func (*ConsensusEngine) ScoreProposal ¶ added in v0.29.14
func (ce *ConsensusEngine) ScoreProposal(proposal *RegistrationProposal, attestations []*Attestation) (float64, map[string]float64)
ScoreProposal computes the trust-weighted score for a proposal
func (*ConsensusEngine) ValidateProposal ¶ added in v0.29.14
func (ce *ConsensusEngine) ValidateProposal(proposal *RegistrationProposal) error
ValidateProposal validates a registration proposal against current state
func (*ConsensusEngine) ValidateTransfer ¶ added in v0.29.14
func (ce *ConsensusEngine) ValidateTransfer(proposal *RegistrationProposal) error
ValidateTransfer validates a transfer proposal
type ConsensusResult ¶ added in v0.29.14
type ConsensusResult struct {
Winner *RegistrationProposal
Score float64
Confidence float64 // 0.0 to 1.0
Attestations int
Conflicted bool
Reason string
}
ConsensusResult represents the result of consensus computation
type NameRecord ¶
type NameRecord struct {
Event *event.E
Name string
Type string // A, AAAA, CNAME, MX, TXT, NS, SRV
Value string
TTL int // Cache TTL in seconds
Priority int // For MX and SRV records
Weight int // For SRV records
Port int // For SRV records
}
NameRecord represents a kind 30103 event
func ParseNameRecord ¶
func ParseNameRecord(ev *event.E) (*NameRecord, error)
ParseNameRecord parses a kind 30103 event into a NameRecord
type NameState ¶
type NameState struct {
Event *event.E
Name string
Owner string // Current owner pubkey
RegisteredAt time.Time
ProposalID string // Event ID of the registration proposal
Attestations int // Number of attestations
Confidence float64 // Consensus confidence score (0.0 to 1.0)
Expiration time.Time
}
NameState represents a kind 30102 event
type ProposalScore ¶ added in v0.29.14
type ProposalScore struct {
Proposal *RegistrationProposal
Score float64
Attestations []*Attestation
Weights map[string]float64 // Attester pubkey -> weighted score
}
ProposalScore holds scoring information for a proposal
type ProposalState ¶ added in v0.29.14
type ProposalState struct {
Proposal *RegistrationProposal
Attestations []*Attestation
ReceivedAt time.Time
ProcessedAt *time.Time
Timer *time.Timer
}
ProposalState tracks a proposal during its attestation window
type RegistrationProposal ¶
type RegistrationProposal struct {
Event *event.E
Name string
Action string // "register" or "transfer"
PrevOwner string // Previous owner pubkey (for transfers)
PrevSig string // Signature from previous owner (for transfers)
Expiration time.Time
}
RegistrationProposal represents a kind 30100 event
func ParseRegistrationProposal ¶
func ParseRegistrationProposal(ev *event.E) (*RegistrationProposal, error)
ParseRegistrationProposal parses a kind 30100 event into a RegistrationProposal
type RegistryConfig ¶ added in v0.29.14
type RegistryConfig struct {
Enabled bool
AttestationDelay time.Duration
SparseEnabled bool
SamplingRate int
BootstrapServices []string
MinimumAttesters int
}
RegistryConfig holds configuration for the registry service
type RegistryMetrics ¶ added in v0.29.14
type RegistryMetrics struct {
PendingProposals int
TrustMetrics *TrustMetrics
}
RegistryMetrics holds metrics about the registry service
type RegistryService ¶ added in v0.29.14
type RegistryService struct {
// contains filtered or unexported fields
}
RegistryService implements the FIND name registry consensus protocol
func NewRegistryService ¶ added in v0.29.14
func NewRegistryService(ctx context.Context, db database.Database, signer signer.I, config *RegistryConfig) (*RegistryService, error)
NewRegistryService creates a new registry service
func (*RegistryService) GetMetrics ¶ added in v0.29.14
func (rs *RegistryService) GetMetrics() *RegistryMetrics
GetMetrics returns registry service metrics
func (*RegistryService) GetTrustGraph ¶ added in v0.29.14
func (rs *RegistryService) GetTrustGraph() *TrustGraph
GetTrustGraph returns the current trust graph
func (*RegistryService) HandleEvent ¶ added in v0.29.14
func (rs *RegistryService) HandleEvent(ev *event.E) error
HandleEvent processes incoming FIND-related events
func (*RegistryService) OnProposalReceived ¶ added in v0.29.14
func (rs *RegistryService) OnProposalReceived(proposal *RegistrationProposal) error
OnProposalReceived is called when a new proposal is received
func (*RegistryService) QueryNameOwnership ¶ added in v0.29.14
func (rs *RegistryService) QueryNameOwnership(name string) (*NameState, error)
QueryNameOwnership queries the ownership state of a name
func (*RegistryService) Start ¶ added in v0.29.14
func (rs *RegistryService) Start() error
Start starts the registry service
func (*RegistryService) Stop ¶ added in v0.29.14
func (rs *RegistryService) Stop() error
Stop stops the registry service
func (*RegistryService) ValidateProposal ¶ added in v0.29.14
func (rs *RegistryService) ValidateProposal(proposal *RegistrationProposal) error
ValidateProposal validates a proposal without adding it to pending
type TransferAuthorization ¶
TransferAuthorization represents the message signed for transfer authorization
func PrepareTransferAuth ¶
func PrepareTransferAuth(name, newOwner string, timestamp time.Time) TransferAuthorization
PrepareTransferAuth prepares the transfer authorization data that needs to be signed This is a helper for wallets/clients that want to show what they're signing
type TrustEntry ¶
TrustEntry represents a single trust relationship
type TrustGraph ¶
type TrustGraph struct {
// contains filtered or unexported fields
}
TrustGraph manages trust relationships between registry services
func NewTrustGraph ¶
func NewTrustGraph(selfPubkey []byte) *TrustGraph
NewTrustGraph creates a new trust graph
func (*TrustGraph) AddEntry ¶ added in v0.29.14
func (tg *TrustGraph) AddEntry(entry TrustEntry) error
AddEntry adds a trust entry to the graph
func (*TrustGraph) AddTrustGraph ¶ added in v0.29.14
func (tg *TrustGraph) AddTrustGraph(graph *TrustGraph) error
AddTrustGraph adds a trust graph from another registry service
func (*TrustGraph) CalculateTrustMetrics ¶ added in v0.29.14
func (tg *TrustGraph) CalculateTrustMetrics() *TrustMetrics
CalculateTrustMetrics computes metrics about the trust graph
func (*TrustGraph) ExportTrustGraph ¶ added in v0.29.14
func (tg *TrustGraph) ExportTrustGraph() *TrustGraphEvent
ExportTrustGraph exports the trust graph for this service as a TrustGraphEvent
func (*TrustGraph) GetAllEntries ¶ added in v0.29.14
func (tg *TrustGraph) GetAllEntries() map[string][]TrustEntry
GetAllEntries returns all trust entries in the graph (for debugging/export)
func (*TrustGraph) GetDirectTrust ¶ added in v0.29.14
func (tg *TrustGraph) GetDirectTrust() []TrustEntry
GetDirectTrust returns direct trust relationships (0-hop only)
func (*TrustGraph) GetInheritedTrust ¶ added in v0.29.14
func (tg *TrustGraph) GetInheritedTrust(fromPubkey, toPubkey string) (float64, []string)
GetInheritedTrust computes inherited trust from one service to another This is useful for debugging and understanding trust propagation
func (*TrustGraph) GetTrustLevel ¶ added in v0.29.14
func (tg *TrustGraph) GetTrustLevel(pubkey []byte) float64
GetTrustLevel returns the trust level for a given pubkey (0.0 to 1.0) This computes both direct trust and inherited trust through the web of trust
func (*TrustGraph) GetTrustedServices ¶ added in v0.29.14
func (tg *TrustGraph) GetTrustedServices() []string
GetTrustedServices returns a list of all directly trusted service pubkeys
func (*TrustGraph) RemoveEntry ¶ added in v0.29.14
func (tg *TrustGraph) RemoveEntry(pubkey string)
RemoveEntry removes a trust entry for a given pubkey
func (*TrustGraph) UpdateEntry ¶ added in v0.29.14
func (tg *TrustGraph) UpdateEntry(pubkey string, newScore float64) error
UpdateEntry updates an existing trust entry
type TrustGraphEvent ¶ added in v0.29.14
type TrustGraphEvent struct {
Event *event.E
Entries []TrustEntry
Expiration time.Time
}
TrustGraphEvent represents a kind 30101 event (renamed to avoid conflict with TrustGraph manager in trust.go)
func ParseTrustGraph ¶
func ParseTrustGraph(ev *event.E) (*TrustGraphEvent, error)
ParseTrustGraph parses a kind 30101 event into a TrustGraphEvent
type TrustMetrics ¶ added in v0.29.14
type TrustMetrics struct {
TotalServices int
DirectTrust int
IndirectTrust int
AverageTrust float64
TrustDistribution map[string]int // high/medium/low/minimal counts
}
TrustMetrics holds metrics about the trust graph
type WitnessMessage ¶
type WitnessMessage struct {
CertPubkey string
Name string
ValidFrom time.Time
ValidUntil time.Time
Challenge string
}
WitnessMessage represents the message signed by witnesses
type WitnessService ¶
type WitnessService struct {
Event *event.E
Endpoint string
Challenges []string // Supported challenge types: "txt", "http", "event"
MaxValidity int // Maximum certificate validity in seconds
Fee int // Fee in sats per certificate
ReputationID string // Event ID of reputation event
Description string
Contact string
Expiration time.Time
}
WitnessService represents a kind 30105 event
func ParseWitnessService ¶
func ParseWitnessService(ev *event.E) (*WitnessService, error)
ParseWitnessService parses a kind 30105 event into a WitnessService
type WitnessSignature ¶
WitnessSignature represents a witness attestation on a certificate
func RequestWitnessSignature ¶
func RequestWitnessSignature(cert *Certificate, witnessSigner signer.I) (WitnessSignature, error)
RequestWitnessSignature creates a witness signature for a certificate This would typically be called by a witness service
Source Files
¶
- builder.go
- certificate.go
- consensus.go
- parser.go
- registry.go
- sign.go
- transfer.go
- trust.go
- types.go
- validation.go
- verify.go