diff --git a/crypto/key.go b/crypto/key.go index b9fdcd17..bc7a1d8a 100644 --- a/crypto/key.go +++ b/crypto/key.go @@ -401,6 +401,11 @@ func (key *Key) GetSHA256Fingerprints() (fingerprints []string) { return } +// GetSHA256Fingerprint computes the SHA256 fingerprints of the primary key. +func (key *Key) GetSHA256Fingerprint() (fingerprints string) { + return hex.EncodeToString(getSHA256FingerprintBytes(key.entity.PrimaryKey)) +} + // GetJsonSHA256Fingerprints returns the SHA256 fingerprints of key and subkeys // encoded in JSON, for gomobile clients that cannot handle arrays. func (key *Key) GetJsonSHA256Fingerprints() ([]byte, error) { diff --git a/crypto/key_test.go b/crypto/key_test.go index c46ef6ea..0c051e4f 100644 --- a/crypto/key_test.go +++ b/crypto/key_test.go @@ -342,6 +342,8 @@ func TestGetSHA256FingerprintsV4(t *testing.T) { assert.Len(t, sha256Fingerprints, 2) assert.Exactly(t, "d9ac0b857da6d2c8be985b251a9e3db31e7a1d2d832d1f07ebe838a9edce9c24", sha256Fingerprints[0]) assert.Exactly(t, "203dfba1f8442c17e59214d9cd11985bfc5cc8721bb4a71740dd5507e58a1a0d", sha256Fingerprints[1]) + + assert.Exactly(t, "d9ac0b857da6d2c8be985b251a9e3db31e7a1d2d832d1f07ebe838a9edce9c24", publicKey.GetSHA256Fingerprint()) } func TestGetEntity(t *testing.T) {