fingerprint

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fingerprint implements Signal's safety-number fingerprints: the numeric DisplayableFingerprint (a 60-digit human-comparable string) and the ScannableFingerprint (a protobuf for QR-code comparison). It mirrors rust/protocol/src/fingerprint.rs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVersionMismatch is returned by Compare when the two fingerprints carry
	// different versions. Mirrors Error::VersionMismatch.
	ErrVersionMismatch = errors.New("fingerprint: version mismatch")
	// ErrParsing is returned when a scannable protobuf is malformed or a
	// fingerprint is too short to encode. Mirrors Error::ParsingError.
	ErrParsing = errors.New("fingerprint: parsing error")
	// ErrInvalidIterationCount is returned when the requested iteration count is
	// outside (1, 1_000_000]. Mirrors Error::InvalidIterationCount.
	ErrInvalidIterationCount = errors.New("fingerprint: invalid iteration count")
)

Error sentinels, wrapped with %w so callers can match with errors.Is. They mirror fingerprint.rs Error.

Functions

This section is empty.

Types

type DisplayableFingerprint

type DisplayableFingerprint struct {
	// contains filtered or unexported fields
}

DisplayableFingerprint is the numeric safety number: two 30-digit halves (local and remote), rendered in a stable order. Mirrors DisplayableFingerprint.

func (DisplayableFingerprint) String

func (d DisplayableFingerprint) String() string

String renders the safety number as the concatenation of the two halves in ascending lexicographic order, so both parties compute the identical 60-digit string regardless of who is "local". Mirrors the Display impl.

type Fingerprint

type Fingerprint struct {
	Display   DisplayableFingerprint
	Scannable ScannableFingerprint
}

Fingerprint bundles the numeric (Display) and scannable forms for a pair of identities. Mirrors Fingerprint.

func New

func New(
	version uint32,
	iterations uint32,
	localID []byte,
	localKey curve.PublicKey,
	remoteID []byte,
	remoteKey curve.PublicKey,
) (*Fingerprint, error)

New builds a Fingerprint for the (local, remote) identity pair at the given version and iteration count. The display string is identical for both parties (it sorts the halves); the scannable form is version-specific. Mirrors Fingerprint::new.

func (*Fingerprint) DisplayString

func (f *Fingerprint) DisplayString() string

DisplayString returns the 60-digit numeric safety number. Mirrors Fingerprint::display_string.

type ScannableFingerprint

type ScannableFingerprint struct {
	// contains filtered or unexported fields
}

ScannableFingerprint is the QR-comparison form: a version plus the two 32-byte per-side fingerprints. Mirrors ScannableFingerprint.

func DeserializeScannableFingerprint

func DeserializeScannableFingerprint(protobuf []byte) (ScannableFingerprint, error)

DeserializeScannableFingerprint decodes a CombinedFingerprints protobuf. Malformed input or a missing field returns an error and never panics. Mirrors ScannableFingerprint::deserialize.

func (ScannableFingerprint) Compare

func (s ScannableFingerprint) Compare(combined []byte) (bool, error)

Compare reports whether the serialized CombinedFingerprints in combined match this fingerprint: their local must equal our remote and their remote must equal our local (the parties hold mirror-image views). A version mismatch is a typed error, not a false result. The content comparison is constant-time. Mirrors ScannableFingerprint::compare.

func (ScannableFingerprint) Serialize

func (s ScannableFingerprint) Serialize() ([]byte, error)

Serialize encodes the scannable fingerprint as a CombinedFingerprints protobuf. Mirrors ScannableFingerprint::serialize.

func (ScannableFingerprint) Version

func (s ScannableFingerprint) Version() uint32

Version returns the scannable fingerprint's version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL