Skip to content
Snippets Groups Projects
Commit 372fd7b9 authored by Bernardo Cardoso's avatar Bernardo Cardoso
Browse files

Merge branch 'master' into keyLifecycle

parents 913e27cd 55b1020e
Branches
Tags
No related merge requests found
...@@ -174,5 +174,12 @@ public class PaymentReceiptListener implements Bindings.Listener { ...@@ -174,5 +174,12 @@ public class PaymentReceiptListener implements Bindings.Listener {
} }
``` ```
After the payer's clients and payee's clients have gone through all of these steps, you'll have successfully processed a payment transaction. ### Cyclic group for registration JSON format:
```json
{
"gen": "5c7ff6b06f8f143fe8288433493e4769c4d988ace5be25a0e24809670716c613d7b0cee6932f8faa7c44d2cb24523da53fbe4f6ec3595892d1aa58c4328a06c46a15662e7eaa703a1decf8bbb2d05dbe2eb956c142a338661d10461c0d135472085057f3494309ffa73c611f78b32adbb5740c361c9f35be90997db2014e2ef5aa61782f52abeb8bd6432c4dd097bc5423b285dafb60dc364e8161f4a2a35aca3a10b1c4d203cc76a470a33afdcbdd92959859abd8b56e1725252d78eac66e71ba9ae3f1dd2487199874393cd4d832186800654760e1e34c09e4d155179f9ec0dc4473f996bdce6eed1cabed8b6f116f7ad9cf505df0f998e34ab27514b0ffe7",
"prime": "9db6fb5951b66bb6fe1e140f1d2ce5502374161fd6538df1648218642f0b5c48c8f7a41aadfa187324b87674fa1822b00f1ecf8136943d7c55757264e5a1a44ffe012e9936e00c1d3e9310b01c7d179805d3058b2a9f4bb6f9716bfe6117c6b5b3cc4d9be341104ad4a80ad6c94e005f4b993e14f091eb51743bf33050c38de235567e1b34c3d6a5c0ceaa1a0f368213c3d19843d0b4b09dcb9fc72d39c8de41f1bf14d4bb4563ca28371621cad3324b6a2d392145bebfac748805236f5ca2fe92b871cd8f9c36d3292b5509ca8caa77a2adfc7bfd77dda6f71125a7456fea153e433256a2261c6a06ed3693797e7995fad5aabbcfbe3eda2741e375404ae25b",
"primeQ": "f2c3119374ce76c9356990b465374a17f23f9ed35089bd969f61c6dde9998c1f"
}
```
...@@ -146,13 +146,20 @@ func InitClient(storage Storage, loc string) error { ...@@ -146,13 +146,20 @@ func InitClient(storage Storage, loc string) error {
// “Jono” // “Jono”
// OIF3OJ5I // OIF3OJ5I
func Register(registrationCode string, gwAddr string, numNodes int, func Register(registrationCode string, gwAddr string, numNodes int,
mint bool, grp *cyclic.Group) ([]byte, error) { mint bool, grpJSON string) ([]byte, error) {
if numNodes < 1 { if numNodes < 1 {
return id.ZeroID[:], errors.New("invalid number of nodes") return id.ZeroID[:], errors.New("invalid number of nodes")
} }
UID, err := api.Register(registrationCode, gwAddr, uint(numNodes), mint, grp) // Unmarshal group JSON
var grp cyclic.Group
err := grp.UnmarshalJSON([]byte(grpJSON))
if err != nil {
return id.ZeroID[:], err
}
UID, err := api.Register(registrationCode, gwAddr, uint(numNodes), mint, &grp)
if err != nil { if err != nil {
return id.ZeroID[:], err return id.ZeroID[:], err
......
...@@ -147,8 +147,12 @@ func TestRegister(t *testing.T) { ...@@ -147,8 +147,12 @@ func TestRegister(t *testing.T) {
g := large.NewInt(2) g := large.NewInt(2)
q := large.NewInt(3) q := large.NewInt(3)
grp := cyclic.NewGroup(p, g, q) grp := cyclic.NewGroup(p, g, q)
grpJSON, err := grp.MarshalJSON()
if err != nil {
t.Errorf("Failed to marshal group JSON: %s", err)
}
regRes, err := Register(registrationCode, gwAddress, 1, false, grp) regRes, err := Register(registrationCode, gwAddress, 1, false, string(grpJSON))
if err != nil { if err != nil {
t.Errorf("Registration failed: %s", err.Error()) t.Errorf("Registration failed: %s", err.Error())
} }
...@@ -170,8 +174,12 @@ func TestRegisterBadNumNodes(t *testing.T) { ...@@ -170,8 +174,12 @@ func TestRegisterBadNumNodes(t *testing.T) {
g := large.NewInt(int64(2)) g := large.NewInt(int64(2))
q := large.NewInt(int64(3)) q := large.NewInt(int64(3))
grp := cyclic.NewGroup(p, g, q) grp := cyclic.NewGroup(p, g, q)
grpJSON, err := grp.MarshalJSON()
if err != nil {
t.Errorf("Failed to marshal group JSON: %s", err)
}
_, err = Register(registrationCode, gwAddress, 0, false, grp) _, err = Register(registrationCode, gwAddress, 0, false, string(grpJSON))
if err == nil { if err == nil {
t.Errorf("Registration worked with bad numnodes! %s", err.Error()) t.Errorf("Registration worked with bad numnodes! %s", err.Error())
} }
...@@ -202,8 +210,12 @@ func TestLoginLogout(t *testing.T) { ...@@ -202,8 +210,12 @@ func TestLoginLogout(t *testing.T) {
g := large.NewInt(2) g := large.NewInt(2)
q := large.NewInt(3) q := large.NewInt(3)
grp := cyclic.NewGroup(p, g, q) grp := cyclic.NewGroup(p, g, q)
grpJSON, err := grp.MarshalJSON()
if err != nil {
t.Errorf("Failed to marshal group JSON: %s", err)
}
regRes, err := Register(registrationCode, gwAddress, 1, false, grp) regRes, err := Register(registrationCode, gwAddress, 1, false, string(grpJSON))
loginRes, err2 := Login(regRes, gwAddress, "") loginRes, err2 := Login(regRes, gwAddress, "")
if err2 != nil { if err2 != nil {
t.Errorf("Login failed: %s", err.Error()) t.Errorf("Login failed: %s", err.Error())
...@@ -216,6 +228,7 @@ func TestLoginLogout(t *testing.T) { ...@@ -216,6 +228,7 @@ func TestLoginLogout(t *testing.T) {
if err3 != nil { if err3 != nil {
t.Errorf("Logoutfailed: %s", err.Error()) t.Errorf("Logoutfailed: %s", err.Error())
} }
globals.LocalStorage = nil globals.LocalStorage = nil
} }
......
...@@ -22,7 +22,6 @@ import ( ...@@ -22,7 +22,6 @@ import (
"gitlab.com/elixxir/client/parse" "gitlab.com/elixxir/client/parse"
"gitlab.com/elixxir/client/user" "gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/comms/connect" "gitlab.com/elixxir/comms/connect"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/switchboard" "gitlab.com/elixxir/primitives/switchboard"
...@@ -122,16 +121,10 @@ func sessionInitialization() { ...@@ -122,16 +121,10 @@ func sessionInitialization() {
// FIXME Use a different encoding for the user ID command line argument, // FIXME Use a different encoding for the user ID command line argument,
// to allow testing with IDs that are long enough to exercise more than // to allow testing with IDs that are long enough to exercise more than
// 64 bits // 64 bits
grp := cyclic.Group{} grpJSON := viper.GetString("group")
grpBuff := []byte(viper.GetString("group"))
err := grp.UnmarshalJSON(grpBuff)
if err != nil {
fmt.Printf("Could Not Decode group from JSON: %s\n", err.Error())
return
}
regCode := new(id.User).SetUints(&[4]uint64{0, 0, 0, userId}).RegistrationCode() regCode := new(id.User).SetUints(&[4]uint64{0, 0, 0, userId}).RegistrationCode()
_, err = bindings.Register(regCode, gwAddr, int(numNodes), mint, &grp) _, err = bindings.Register(regCode, gwAddr, int(numNodes), mint, grpJSON)
if err != nil { if err != nil {
fmt.Printf("Could Not Register User: %s\n", err.Error()) fmt.Printf("Could Not Register User: %s\n", err.Error())
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment