git.gammaspectra.live/P2Pool/consensus@v0.0.0-20240403173234-a039820b20c9/monero/crypto/comm.go (about) 1 package crypto 2 3 import ( 4 "git.gammaspectra.live/P2Pool/consensus/types" 5 ) 6 7 // SignatureComm Used in normal message signatures 8 type SignatureComm struct { 9 Hash types.Hash 10 Key PublicKey 11 Comm PublicKey 12 } 13 14 func (s *SignatureComm) Bytes() []byte { 15 buf := make([]byte, 0, types.HashSize+PublicKeySize*2) 16 buf = append(buf, s.Hash[:]...) 17 buf = append(buf, s.Key.AsSlice()...) 18 buf = append(buf, s.Comm.AsSlice()...) 19 return buf 20 } 21 22 // SignatureComm_2 Used in v1/v2 tx proofs 23 type SignatureComm_2 struct { 24 Message types.Hash 25 // KeyDerivation D 26 KeyDerivation PublicKey 27 // RandomPublicKey X 28 RandomPublicKey PublicKey 29 // RandomDerivation Y 30 RandomDerivation PublicKey 31 // Separator Domain Separation 32 Separator types.Hash 33 // TransactionPublicKey R 34 TransactionPublicKey PublicKey 35 // RecipientViewPublicKey A 36 RecipientViewPublicKey PublicKey 37 RecipientSpendPublicKey PublicKey 38 } 39 40 func (s *SignatureComm_2) Bytes() []byte { 41 buf := make([]byte, 0, types.HashSize*2+PublicKeySize*6) 42 buf = append(buf, s.Message[:]...) 43 buf = append(buf, s.KeyDerivation.AsSlice()...) 44 buf = append(buf, s.RandomPublicKey.AsSlice()...) 45 buf = append(buf, s.RandomDerivation.AsSlice()...) 46 buf = append(buf, s.Separator[:]...) 47 buf = append(buf, s.TransactionPublicKey.AsSlice()...) 48 buf = append(buf, s.RecipientViewPublicKey.AsSlice()...) 49 if s.RecipientSpendPublicKey == nil { 50 buf = append(buf, types.ZeroHash[:]...) 51 } else { 52 buf = append(buf, s.RecipientSpendPublicKey.AsSlice()...) 53 } 54 return buf 55 } 56 57 // SignatureComm_2_V1 Used in v1 tx proofs 58 type SignatureComm_2_V1 struct { 59 Message types.Hash 60 // KeyDerivation D 61 KeyDerivation PublicKey 62 // RandomPublicKey X 63 RandomPublicKey PublicKey 64 // RandomDerivation Y 65 RandomDerivation PublicKey 66 } 67 68 func (s *SignatureComm_2_V1) Bytes() []byte { 69 buf := make([]byte, 0, types.HashSize+PublicKeySize*3) 70 buf = append(buf, s.Message[:]...) 71 buf = append(buf, s.KeyDerivation.AsSlice()...) 72 buf = append(buf, s.RandomPublicKey.AsSlice()...) 73 buf = append(buf, s.RandomDerivation.AsSlice()...) 74 return buf 75 }