Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95288093
crypto_javascript.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
Sat, Dec 14, 09:49
Size
7 KB
Mime Type
text/x-c
Expires
Mon, Dec 16, 09:49 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22963649
Attached To
R2664 SHRINE MedCo Fork
crypto_javascript.go
View Options
package
main
import
(
"gopkg.in/dedis/onet.v1/app"
"github.com/gopherjs/gopherjs/js"
"./mylib"
//"./mappingTable"
"os"
)
// build me with: gopherjs build -m crypto_javascript.go -o cryptolib.js
func
main
()
{
//--> transiple the three functions
//transpileFunctions()
//// --> compute the aggregate key of the cothority
f
,
err
:=
os
.
Open
(
"../cothority"
)
if
err
!=
nil
{
print
(
"Error while opening group file: "
,
err
.
Error
())
return
}
el
,
err
:=
app
.
ReadGroupToml
(
f
)
if
err
!=
nil
{
print
(
"Error while reading group file: "
,
err
.
Error
())
return
}
print
(
mylib
.
PointToString
(
el
.
Aggregate
))
//--> check how big is the mapping table
//js.Global.Set("MyPrint", myprint)
//print(len(mappingTable.PointToInt))
//--> encrypt some variants
//encryptAndTest()
}
func
transpileFunctions
(){
js
.
Global
.
Set
(
"GenKey"
,
mylib
.
GenKey
)
js
.
Global
.
Set
(
"EncryptStr"
,
mylib
.
EncryptStr
)
js
.
Global
.
Set
(
"DecryptStr"
,
mylib
.
DecryptStr
)
// also the light encryption
js
.
Global
.
Set
(
"LightEncryptStr_init"
,
mylib
.
LightEncryptStr_init
)
js
.
Global
.
Set
(
"LightEncryptStr"
,
mylib
.
LightEncryptStr
)
}
//
//func encryptAndTest(){
// //pk :="Sdmuk6sblX10oI47OACV/7YJ5EV9xjC4yv3PxaKc+w4=";
// //sk :="zjvEJSm8BHpVqqS7PPy4xSE6n7QIorre1yuhuZ8bzg4=";
// K := "4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyA=";
// S := "25HhZV/HKHaGn+nfJS0hl5VGys3uCjMZtex6THA5/0c=";
//
// plains_str := []string{"-7054948997223410688","-7054948998062267136","-7054968999892742144","-7054948999337337856","-7054948997064022784","-7054953138544961536","-7054948997064020736","-7054923607457132544","-7054904773018905600","-7054898625779855360","-7054948987408734208","-7054923379857424384","-7054917142457610240","-7054861692282335232","-7054948050082458624","-7054922546600210432","-7054949048695910400","-7054923381098933248","-7054861517262417920","-7054918645662608384","-7054905185268658176","-7054904954414166016","-7054898626853597184","-7054904932905773056","-7054861823278837760"};
//
// ciphers := make([]string, len(plains_str))
// for i, _ := range plains_str{
// //plain, _ := strconv.ParseInt(pl, 10, 64)
// ciphers[i] = mylib.LightEncryptStr(plains_str[i], K, S) //strconv.Atoi(pl)
// }
//
// //ciphers_js := []string{"4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyAyv5RvMN3DwobTYDhMq6KwE7Jbi5K2DemSR+e+yMCklQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyBrfx43POcVJBeVWbCv80Mx+z4QHgPRYYjOcyYX9JNAzw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyAx8ZRWteSDfrNQ9lduvoj0/Wq7XJW1Ct8Wv2IyZb4T0Q==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCrGkFfOH5Rccw5NIPl6cNeh6kAW6AkxFtvJ7ysi2ZOsw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCb/fNT38MS0oT1B5+D4+kRbrSqlaYsk7YLYCQiXdhACg==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyBfKtKjZNbqqKcNzQq5ChYqbqI+7V0sFsJJ/JgRNS9fHw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyB+qN/r1RYzFiW9jqN/o3o7D+8U3h8iJQRYKSEXMe6EMA==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDc7zOG56Otw4cPhnjRfZ4WcUg1NguUpI5fwzUUpWlu5Q==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCdOjUH0ApoM8hP2JdrX8qltiyghDDTGSrwDxBOVNVthw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyBbeRwtjCS4Bcc++6QhilACbs9az2JCMkbuOSSbPWKeQg==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyAoGWkJCpj6w9YnOeTbPORuDTy+IEFaEztSwCDg1zHGxA==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDqCtcWqfDtSzWSg2TZlmNwoPcIm0YJM1VnAu0pM4JzxQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDUuPl/3dPVEivoycWWNBcbHIklX0QXQTsppLd2zBWvDw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyBDOGVAecu1k33lB5MgcMAv947zzirc9zG+XZI0LF2wPw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCB7O+RPPkWXzB77OUbVsIOAuxtos7xuwLlXhG25GEGnQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCccW3uc6pMdJ8/v2+j2Jji/fFg93ZrK9NMZJnzzLQCug==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyC76GIXmrw/adl5aBhNRsljBzHTU1UlilFpBh3+XQXbxw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDFR+1/JfJYkJm6PjBBBIVFCuppYo5Q/SkXYjk4Zx/Xrg==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyAymMpHIGtkR1pUlVFEly5JxV5awErRk+8ZKI2lyoXtlQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCkuDdatd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kvtBxMNlbyFGvFJss5tKFSIL8uHlUrVkog==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDc7zOG56Otw4cPhnjRfZ4WcUg1NguUpI5fwzUUpWlu5Q==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCdOjUH0ApoM8hP2JdrX8qltiyghDDTGSrwDxBOVNVthw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyBbeRwtjCS4Bcc++6QhilACbs9az2JCMkbuOSSbPWKeQg==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyAoGWkJCpj6w9YnOeTbPORuDTy+IEFaEztSwCDg1zHGxA==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDqCtcWqfDtSzWSg2TZlmNwoPcIm0YJM1VnAu0pM4JzxQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDUuPl/3dPVEivoycWWNBcbHIklX0QXQTsppLd2zBWvDw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyBDOGVAecu1k33lB5MgcMAv947zzirc9zG+XZI0LF2wPw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCB7O+RPPkWXzB77OUbVsIOAuxtos7xuwLlXhG25GEGnQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCccW3uc6pMdJ8/v2+j2Jji/fFg93ZrK9NMZJnzzLQCug==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyC76GIXmrw/adl5aBhNRsljBzHTU1UlilFpBh3+XQXbxw==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDFR+1/JfJYkJm6PjBBBIVFCuppYo5Q/SkXYjk4Zx/Xrg==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyAymMpHIGtkR1pUlVFEly5JxV5awErRk+8ZKI2lyoXtlQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCkuDdatdqfD0vng59j3RTG/qJWvQvPOOiRJFOXNcoZiQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyC/WGiMxn3fk/3EWOxaNN0Gq68d6g0/DPoOm3SI34NsTg==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyCSJgbnpNrzKpD0nKqrP8P4i7wuQtYcFTzdfQ9ftBA3ug==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyANhOFURQ8tCCy5AFw21WFxzU6GA9WCAHCyQw5JP1wX5Q==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyDtVbDm8bPsDbVEDhcO0G92/bKx8K3/otFtdCSLeG/9vQ==","4zKXNX74MKVSWMZGScdiOBea+kra3W7CdZvVkhX+yyC+bqr3iEhbhbaGrJ9ROldzfvZm+zeKwfNtchxVCI2CYQ=="}
//
// println(strings.Join(ciphers,","))
// println(strings.Join(ciphers_js,","), "\n")
// diff := ciphersDifferent(ciphers, ciphers_js)
// for i,_ := range diff{
// println(plains_str[i], "correct enc: ", ciphers[i], "wrong enc: ", ciphers_js[i])
// }
//
// //for _, i := range diff{
// // println("\n", plains[i], ":")
// // for j, _ := range plains{
// // if !intInSlice(j, diff){
// // println(i, "<", j, plains[i]<plains[j])
// // }
// // }
// // print()
// //}
//}
//
//func ciphersDifferent(a []string, b []string) []int {
// if len(a) != len(b) {
// return []int{-1}
// }
//
// diffCiphers := []int{}
// for i, v := range a {
//
// if v != b[i] {
// diffCiphers = append(diffCiphers, i)
// }
// }
// return diffCiphers
//}
//
//func intInSlice(a int, list []int) bool {
// for _, b := range list {
// if b == a {
// return true
// }
// }
// return false
//}
Event Timeline
Log In to Comment