Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91072727
main.go
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Nov 7, 14:22
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Nov 9, 14:22 (2 d)
Engine
blob
Format
Raw Data
Handle
22190762
Attached To
R2664 SHRINE MedCo Fork
main.go
View Options
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
Log In to Comment