diff options
Diffstat (limited to 'whisper')
-rw-r--r-- | whisper/whisperv5/api.go | 42 | ||||
-rw-r--r-- | whisper/whisperv5/api_test.go | 24 |
2 files changed, 33 insertions, 33 deletions
diff --git a/whisper/whisperv5/api.go b/whisper/whisperv5/api.go index 841bbc2ba..1a4e4d879 100644 --- a/whisper/whisperv5/api.go +++ b/whisper/whisperv5/api.go @@ -231,14 +231,14 @@ func (api *PublicWhisperAPI) Subscribe(args WhisperFilterArgs) (string, error) { return "", errors.New("subscribe: " + err.Error()) } - if len(args.SignedWith) > 0 { - sb := common.FromHex(args.SignedWith) + if len(args.Sig) > 0 { + sb := common.FromHex(args.Sig) if sb == nil { - return "", errors.New("subscribe: SignedWith parameter is invalid") + return "", errors.New("subscribe: sig parameter is invalid") } filter.Src = crypto.ToECDSAPub(sb) if !ValidatePublicKey(filter.Src) { - return "", errors.New("subscribe: invalid 'SignedWith' field") + return "", errors.New("subscribe: invalid 'sig' field") } } @@ -319,8 +319,8 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error { return errors.New("post: key is missing") } - if len(args.SignWith) > 0 { - params.Src, err = api.whisper.GetPrivateKey(args.SignWith) + if len(args.Sig) > 0 { + params.Src, err = api.whisper.GetPrivateKey(args.Sig) if err != nil { return err } @@ -391,7 +391,7 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error { type PostArgs struct { Type string `json:"type"` // "sym"/"asym" (symmetric or asymmetric) TTL uint32 `json:"ttl"` // time-to-live in seconds - SignWith string `json:"signWith"` // id of the signing key + Sig string `json:"sig"` // id of the signing key Key string `json:"key"` // key id (in case of sym) or public key (in case of asym) Topic hexutil.Bytes `json:"topic"` // topic (4 bytes) Padding hexutil.Bytes `json:"padding"` // optional padding bytes @@ -402,12 +402,12 @@ type PostArgs struct { } type WhisperFilterArgs struct { - Symmetric bool // encryption type - Key string // id of the key to be used for decryption - SignedWith string // public key of the sender to be verified - MinPoW float64 // minimal PoW requirement - Topics [][]byte // list of topics (up to 4 bytes each) to match - AllowP2P bool // indicates wheather direct p2p messages are allowed for this filter + Symmetric bool // encryption type + Key string // id of the key to be used for decryption + Sig string // public key of the sender to be verified + MinPoW float64 // minimal PoW requirement + Topics [][]byte // list of topics (up to 4 bytes each) to match + AllowP2P bool // indicates wheather direct p2p messages are allowed for this filter } // UnmarshalJSON implements the json.Unmarshaler interface, invoked to convert a @@ -415,12 +415,12 @@ type WhisperFilterArgs struct { func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) { // Unmarshal the JSON message and sanity check var obj struct { - Type string `json:"type"` - Key string `json:"key"` - SignedWith string `json:"signedWith"` - MinPoW float64 `json:"minPoW"` - Topics []interface{} `json:"topics"` - AllowP2P bool `json:"allowP2P"` + Type string `json:"type"` + Key string `json:"key"` + Sig string `json:"sig"` + MinPoW float64 `json:"minPoW"` + Topics []interface{} `json:"topics"` + AllowP2P bool `json:"allowP2P"` } if err := json.Unmarshal(b, &obj); err != nil { return err @@ -436,7 +436,7 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) { } args.Key = obj.Key - args.SignedWith = obj.SignedWith + args.Sig = obj.Sig args.MinPoW = obj.MinPoW args.AllowP2P = obj.AllowP2P @@ -472,7 +472,7 @@ type WhisperMessage struct { Topic string `json:"topic"` Payload string `json:"payload"` Padding string `json:"padding"` - Src string `json:"signedWith"` + Src string `json:"sig"` Dst string `json:"recipientPublicKey"` Timestamp uint32 `json:"timestamp"` TTL uint32 `json:"ttl"` diff --git a/whisper/whisperv5/api_test.go b/whisper/whisperv5/api_test.go index c837b0a14..a6d82d850 100644 --- a/whisper/whisperv5/api_test.go +++ b/whisper/whisperv5/api_test.go @@ -173,7 +173,7 @@ func TestUnmarshalFilterArgs(t *testing.T) { s := []byte(`{ "type":"sym", "key":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d", - "signedWith":"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", + "sig":"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", "minPoW":2.34, "topics":["0x00000000", "0x007f80ff", "0xff807f00", "0xf26e7779"], "allowP2P":true @@ -191,8 +191,8 @@ func TestUnmarshalFilterArgs(t *testing.T) { if f.Key != "0x70c87d191324e6712a591f304b4eedef6ad9bb9d" { t.Fatalf("wrong key: %s.", f.Key) } - if f.SignedWith != "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83" { - t.Fatalf("wrong SignedWith: %s.", f.SignedWith) + if f.Sig != "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83" { + t.Fatalf("wrong sig: %s.", f.Sig) } if f.MinPoW != 2.34 { t.Fatalf("wrong MinPoW: %f.", f.MinPoW) @@ -229,7 +229,7 @@ func TestUnmarshalPostArgs(t *testing.T) { s := []byte(`{ "type":"sym", "ttl":12345, - "signWith":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d", + "sig":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d", "key":"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", "topic":"0xf26e7779", "padding":"0x74686973206973206D79207465737420737472696E67", @@ -251,8 +251,8 @@ func TestUnmarshalPostArgs(t *testing.T) { if a.TTL != 12345 { t.Fatalf("wrong ttl: %d.", a.TTL) } - if a.SignWith != "0x70c87d191324e6712a591f304b4eedef6ad9bb9d" { - t.Fatalf("wrong From: %s.", a.SignWith) + if a.Sig != "0x70c87d191324e6712a591f304b4eedef6ad9bb9d" { + t.Fatalf("wrong From: %s.", a.Sig) } if a.Key != "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83" { t.Fatalf("wrong Key: %s.", a.Key) @@ -347,7 +347,7 @@ func TestIntegrationAsym(t *testing.T) { var f WhisperFilterArgs f.Symmetric = false f.Key = key - f.SignedWith = sigPubKey.String() + f.Sig = sigPubKey.String() f.Topics = make([][]byte, 2) f.Topics[0] = topics[0][:] f.Topics[1] = topics[1][:] @@ -362,7 +362,7 @@ func TestIntegrationAsym(t *testing.T) { var p PostArgs p.Type = "asym" p.TTL = 2 - p.SignWith = sig + p.Sig = sig p.Key = dstPubKey.String() p.Padding = []byte("test string") p.Payload = []byte("extended test string") @@ -449,7 +449,7 @@ func TestIntegrationSym(t *testing.T) { f.Topics[0] = topics[0][:] f.Topics[1] = topics[1][:] f.MinPoW = DefaultMinimumPoW / 2 - f.SignedWith = sigPubKey.String() + f.Sig = sigPubKey.String() f.AllowP2P = false id, err := api.Subscribe(f) @@ -461,7 +461,7 @@ func TestIntegrationSym(t *testing.T) { p.Type = "sym" p.TTL = 1 p.Key = symKeyID - p.SignWith = sig + p.Sig = sig p.Padding = []byte("test string") p.Payload = []byte("extended test string") p.PowTarget = DefaultMinimumPoW @@ -547,7 +547,7 @@ func TestIntegrationSymWithFilter(t *testing.T) { f.Topics[0] = topics[0][:] f.Topics[1] = topics[1][:] f.MinPoW = DefaultMinimumPoW / 2 - f.SignedWith = sigPubKey.String() + f.Sig = sigPubKey.String() f.AllowP2P = false id, err := api.Subscribe(f) @@ -559,7 +559,7 @@ func TestIntegrationSymWithFilter(t *testing.T) { p.Type = "sym" p.TTL = 1 p.Key = symKeyID - p.SignWith = sigKeyID + p.Sig = sigKeyID p.Padding = []byte("test string") p.Payload = []byte("extended test string") p.PowTarget = DefaultMinimumPoW |