mirror of https://github.com/status-im/op-geth.git
Changed public whisper api not to reveal temporary private keys
This commit is contained in:
parent
bb55307a9d
commit
62e0e18030
|
@ -1,4 +1,4 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.1
|
||||||
import QtWebKit 3.0
|
import QtWebKit 3.0
|
||||||
import QtWebKit.experimental 1.0
|
import QtWebKit.experimental 1.0
|
||||||
import QtQuick.Controls 1.0;
|
import QtQuick.Controls 1.0;
|
||||||
|
@ -164,6 +164,35 @@ Rectangle {
|
||||||
|
|
||||||
|
|
||||||
experimental.preferences.javascriptEnabled: true
|
experimental.preferences.javascriptEnabled: true
|
||||||
|
experimental.preferences.webGLEnabled: true
|
||||||
|
experimental.itemSelector: MouseArea {
|
||||||
|
// To avoid conflicting with ListView.model when inside Initiator context.
|
||||||
|
property QtObject selectorModel: model
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: selectorModel.reject()
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
visible: true
|
||||||
|
id: itemSelector
|
||||||
|
|
||||||
|
Instantiator {
|
||||||
|
model: selectorModel.items
|
||||||
|
delegate: MenuItem {
|
||||||
|
text: model.text
|
||||||
|
onTriggered: {
|
||||||
|
selectorModel.accept(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onObjectAdded: itemSelector.insertItem(index, object)
|
||||||
|
onObjectRemoved: itemSelector.removeItem(object)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
itemSelector.popup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
experimental.preferences.webAudioEnabled: true
|
||||||
experimental.preferences.navigatorQtObjectEnabled: true
|
experimental.preferences.navigatorQtObjectEnabled: true
|
||||||
experimental.preferences.developerExtrasEnabled: true
|
experimental.preferences.developerExtrasEnabled: true
|
||||||
experimental.userScripts: ["../ext/q.js", "../ext/ethereum.js/lib/web3.js", "../ext/ethereum.js/lib/qt.js", "../ext/setup.js"]
|
experimental.userScripts: ["../ext/q.js", "../ext/ethereum.js/lib/web3.js", "../ext/ethereum.js/lib/qt.js", "../ext/setup.js"]
|
||||||
|
@ -362,6 +391,10 @@ Rectangle {
|
||||||
postData(data._id, messages);
|
postData(data._id, messages);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "ssh_newGroup":
|
||||||
|
postData(data._id, "");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(data.call + ": " + e)
|
console.log(data.call + ": " + e)
|
||||||
|
|
|
@ -17,7 +17,7 @@ func ToQMessage(msg *whisper.Message) *Message {
|
||||||
return &Message{
|
return &Message{
|
||||||
ref: msg,
|
ref: msg,
|
||||||
Flags: int32(msg.Flags),
|
Flags: int32(msg.Flags),
|
||||||
Payload: ethutil.Bytes2Hex(msg.Payload),
|
Payload: "0x" + ethutil.Bytes2Hex(msg.Payload),
|
||||||
From: ethutil.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())),
|
From: "0x" + ethutil.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,16 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
|
||||||
data = append(data, fromHex(d)...)
|
data = append(data, fromHex(d)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pk := crypto.ToECDSAPub(fromHex(from))
|
||||||
|
if key := self.Whisper.GetIdentity(pk); key != nil {
|
||||||
msg := whisper.NewMessage(data)
|
msg := whisper.NewMessage(data)
|
||||||
envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{
|
envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{
|
||||||
Ttl: time.Duration(ttl) * time.Second,
|
Ttl: time.Duration(ttl) * time.Second,
|
||||||
To: crypto.ToECDSAPub(fromHex(to)),
|
To: crypto.ToECDSAPub(fromHex(to)),
|
||||||
From: crypto.ToECDSA(fromHex(from)),
|
From: key,
|
||||||
Topics: whisper.TopicsFromString(topics...),
|
Topics: whisper.TopicsFromString(topics...),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlogger.Infoln(err)
|
qlogger.Infoln(err)
|
||||||
// handle error
|
// handle error
|
||||||
|
@ -59,14 +62,20 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
|
||||||
// handle error
|
// handle error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qlogger.Infoln("unmatched pub / priv for seal")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Whisper) NewIdentity() string {
|
func (self *Whisper) NewIdentity() string {
|
||||||
return toHex(self.Whisper.NewIdentity().D.Bytes())
|
key := self.Whisper.NewIdentity()
|
||||||
|
|
||||||
|
return toHex(crypto.FromECDSAPub(&key.PublicKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Whisper) HasIdentity(key string) bool {
|
func (self *Whisper) HasIdentity(key string) bool {
|
||||||
return self.Whisper.HasIdentity(crypto.ToECDSA(fromHex(key)))
|
return self.Whisper.HasIdentity(crypto.ToECDSAPub(fromHex(key)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int {
|
func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int {
|
||||||
|
|
|
@ -60,7 +60,7 @@ type Whisper struct {
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
|
||||||
keys []*ecdsa.PrivateKey
|
keys map[string]*ecdsa.PrivateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *Whisper {
|
func New() *Whisper {
|
||||||
|
@ -69,6 +69,7 @@ func New() *Whisper {
|
||||||
filters: filter.New(),
|
filters: filter.New(),
|
||||||
expiry: make(map[uint32]*set.SetNonTS),
|
expiry: make(map[uint32]*set.SetNonTS),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
|
keys: make(map[string]*ecdsa.PrivateKey),
|
||||||
}
|
}
|
||||||
whisper.filters.Start()
|
whisper.filters.Start()
|
||||||
|
|
||||||
|
@ -101,18 +102,18 @@ func (self *Whisper) NewIdentity() *ecdsa.PrivateKey {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
self.keys = append(self.keys, key)
|
|
||||||
|
self.keys[string(crypto.FromECDSAPub(&key.PublicKey))] = key
|
||||||
|
|
||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Whisper) HasIdentity(key *ecdsa.PrivateKey) bool {
|
func (self *Whisper) HasIdentity(key *ecdsa.PublicKey) bool {
|
||||||
for _, key := range self.keys {
|
return self.keys[string(crypto.FromECDSAPub(key))] != nil
|
||||||
if key.D.Cmp(key.D) == 0 {
|
}
|
||||||
return true
|
|
||||||
}
|
func (self *Whisper) GetIdentity(key *ecdsa.PublicKey) *ecdsa.PrivateKey {
|
||||||
}
|
return self.keys[string(crypto.FromECDSAPub(key))]
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Whisper) Watch(opts Filter) int {
|
func (self *Whisper) Watch(opts Filter) int {
|
||||||
|
|
Loading…
Reference in New Issue