Page MenuHomec4science

main.go
No OneTemporary

File Metadata

Created
Fri, Jul 26, 03:27
package main
import (
"github.com/gopherjs/gopherjs/js"
"github.com/JoaoAndreSa/MedCo/lib"
)
//var cothorityPublicKey string
/**
* Encapsulate the library in the cryptoJS object that you can
* find the global JS object
*/
func main() {
js.Global.Set("cryptoJSmedcotest", map[string]interface{}{
"IntToPoint": lib.IntToPoint,
"EncryptInt": lib.EncryptInt,
"GenKey": lib.GenKey,
// "Javascript name": gopkg.gofunc,
})
js.Global.Get("document").Call("getElementById", "testtext").Set("innerHTML", "modif from go")
valueEncTest := int64(88)
js.Global.Get("document").Call("getElementById", "testtext").Set("innerHTML", "generating keys...")
secKey, pubKey := lib.GenKey()
js.Global.Get("document").Call("getElementById", "testtext").Set("innerHTML", "keys gen, encrypting...")
encInt := lib.EncryptInt(pubKey, valueEncTest)
js.Global.Get("document").Call("getElementById", "testtext").Set("innerHTML", "encrypted, decrypting...")
decInt := lib.DecryptInt(secKey, *encInt)
js.Global.Get("document").Call("getElementById", "testtext").Set("innerHTML", decInt)
}
// to from JS: only safe to pass (serialized form? -> byte[] using marshal methods, then to string in base64)
// dedis/crypto/base64: encode byte[] - string
// encode what and how exactly? check what they are doing on server side
//first step goal: encode in base64 some value and decode it
// Build a marshal binary of an EdDSA from a simple private key
/*
func KeyPairFromPrivate(privateKey []byte) []byte {
// Build the marshal binary without public key as we don't have it
buf := make([]byte, 64)
copy(buf[:32], privateKey)
// Use it to instantiate a new EdDSA
e := &eddsa.EdDSA{}
e.UnmarshalBinary(buf)
result, _ := e.MarshalBinary()
return result
}
func SetCothorityPublicKey(cothPubKey string) {
cothorityPublicKey := cothPubKey
}
func GetCothorityPublicKey() string {
return cothorityPublicKey
}
*/
//func EncryptInt(value int64?) {
//}

Event Timeline