-
Notifications
You must be signed in to change notification settings - Fork 0
added generaterandomcontract function #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 1 commit
e2284d2
8ed5ff7
171ed51
308d102
7be827d
098b25d
071041b
dd1f0eb
2d3ded8
66438e7
8ba2b33
91fd671
545e1f3
fec9d8a
7f88d5c
f662f84
a6eb843
a2c1d66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,41 +278,20 @@ func (mc *JSONContract) Unmarshal() (Contract, error) { | |
| fmt.print(c) | ||
| } | ||
|
|
||
| func (c *Contract) ContainsPublicKey(pk publickey.AurumPublicKey) (bool, error) { | ||
| if c == nil { | ||
| return false, errors.New("not nill") | ||
| } | ||
|
|
||
| // encode contract's sender pub key to bytes | ||
| bKey, err := publickey.Encode(c.SenderPubKey) | ||
| if err != nil{ | ||
| return bytes.Equal(bKey, pk.Bytes), errors.New("failed to encode sender public key") | ||
| } | ||
| // return the comparison of the above encoding with Bytes field of pk | ||
| return bytes.Equal(bKey, pk.Bytes), nil | ||
|
|
||
| } | ||
|
|
||
| func(c *Contract) GenerateRandomContract() (Contract){ | ||
|
|
||
| funcGenerateRandomContract() Contract{ | ||
harshalpatel165 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| b := rand.Read(make([]byte, 32)) | ||
|
|
||
| genSenderPubKey := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) | ||
|
||
|
|
||
| genrecipPubKeyHash := rand.Read(make([]byte, 32)) | ||
|
||
|
|
||
| genVersion := binary.LittleEndian.Uint16(b[:]) | ||
|
||
|
|
||
| genSigLen := binary.LittleEndian.Uint8(b[:]); | ||
|
|
||
|
|
||
| genSignature := rand.Read(make([]byte, genSigLen)); | ||
|
||
|
|
||
| genValue := binary.LittleEndian.Uint64(b[:]) | ||
|
|
||
| genStateNonce := binary.LittleEndian.Uint64(b[:]) | ||
|
|
||
|
|
||
| c := &Contract{ | ||
| return &Contract{ | ||
harshalpatel165 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Version: genVersion, | ||
| SenderPubKey: genSenderPubKey, | ||
| SigLen: genSigLen, | ||
|
|
@@ -321,7 +300,6 @@ func(c *Contract) GenerateRandomContract() (Contract){ | |
| Value: genValue, | ||
| StateNonce: genStateNonce, | ||
|
|
||
| } | ||
| return c, nil | ||
| }, nil | ||
|
||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.