From fe14ea3b50a95315158a0adcc3e2775fc5d38a76 Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Mon, 20 Feb 2017 20:50:54 -0800 Subject: [PATCH 1/3] Update to support the viewkey encodings in zcash/zips/#117 --- zcash/address.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/zcash/address.go b/zcash/address.go index 6352f81..398d5be 100644 --- a/zcash/address.go +++ b/zcash/address.go @@ -16,7 +16,8 @@ var ( TestSpendingKey = [2]byte{0xAC, 0x08} ProdAddress = [2]byte{0x16, 0x9A} TestAddress = [2]byte{0x16, 0xB6} - ProdViewingKey = [2]byte{0, 0} // Not yet specified - WILL CHANGE + ProdViewingKey = [2]byte{0x0B, 0x1C} + TestViewingKey = [2]byte{0x0B, 0x2A} ) var ( @@ -96,8 +97,9 @@ func KeyToViewingKey(key []byte) ([]byte, error) { if len(key) != 32 || key[0]&0xf0 != 0 { return nil, ErrInvalidKey } - viewKey := make([]byte, 32) - prfAddr(viewKey, key, 1) + viewKey := make([]byte, 64) + prfAddr(viewKey, key, 0) + prfAddr(viewKey[32:], key, 1) return viewKey, nil } From 2d75bc1b455e0cff8d47d8ae49cd90b2e9c20e08 Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Thu, 23 Feb 2017 10:32:59 -0800 Subject: [PATCH 2/3] Clamp the output of addrPRF(1) in the view key to a valid Curve25519 --- zcash/address.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zcash/address.go b/zcash/address.go index 398d5be..9b644e2 100644 --- a/zcash/address.go +++ b/zcash/address.go @@ -100,6 +100,10 @@ func KeyToViewingKey(key []byte) ([]byte, error) { viewKey := make([]byte, 64) prfAddr(viewKey, key, 0) prfAddr(viewKey[32:], key, 1) + //Clamp PRF output to a sections 4.2 and 5.4.6 of the Zcash spec + viewKey[32] &= 248 + viewKey[63] &= 127 + viewKey[63] |= 64 return viewKey, nil } From 1cc534dcf00eda22880fb2073e50fe629e60cfa2 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Fri, 24 Feb 2017 00:25:15 +0530 Subject: [PATCH 3/3] Minor comment change --- zcash/address.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zcash/address.go b/zcash/address.go index 9b644e2..ef2bf5d 100644 --- a/zcash/address.go +++ b/zcash/address.go @@ -100,7 +100,8 @@ func KeyToViewingKey(key []byte) ([]byte, error) { viewKey := make([]byte, 64) prfAddr(viewKey, key, 0) prfAddr(viewKey[32:], key, 1) - //Clamp PRF output to a sections 4.2 and 5.4.6 of the Zcash spec + // Clamp PRF output to a valid Curve25519 secret key. + // (See sections 4.2 and 5.4.6 of the Zcash spec.) viewKey[32] &= 248 viewKey[63] &= 127 viewKey[63] |= 64