Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
136b54fb
Commit
136b54fb
authored
Apr 27, 2022
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
move more precan stuff into precan.go
parent
5ee8906f
No related branches found
No related tags found
2 merge requests
!510
Release
,
!207
WIP: Client Restructure
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/precan.go
+64
-0
64 additions, 0 deletions
api/precan.go
with
64 additions
and
0 deletions
api/precan.go
+
64
−
0
View file @
136b54fb
...
...
@@ -11,11 +11,15 @@ import (
"encoding/binary"
"math/rand"
"github.com/cloudflare/circl/dh/sidh"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/e2e/ratchet/partner/session"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/user"
"gitlab.com/elixxir/crypto/contact"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
...
...
@@ -94,3 +98,63 @@ func NewPrecannedClient(precannedID uint, defJSON, storageDir string,
return
nil
}
// Create an insecure e2e relationship with a precanned user
func
(
c
*
Client
)
MakePrecannedAuthenticatedChannel
(
precannedID
uint
)
(
contact
.
Contact
,
error
)
{
precan
:=
c
.
MakePrecannedContact
(
precannedID
)
myID
:=
binary
.
BigEndian
.
Uint64
(
c
.
GetUser
()
.
GetContact
()
.
ID
[
:
])
// Pick a variant based on if their ID is bigger than mine.
myVariant
:=
sidh
.
KeyVariantSidhA
theirVariant
:=
sidh
.
KeyVariant
(
sidh
.
KeyVariantSidhB
)
if
myID
>
uint64
(
precannedID
)
{
myVariant
=
sidh
.
KeyVariantSidhB
theirVariant
=
sidh
.
KeyVariantSidhA
}
prng1
:=
rand
.
New
(
rand
.
NewSource
(
int64
(
precannedID
)))
theirSIDHPrivKey
:=
util
.
NewSIDHPrivateKey
(
theirVariant
)
theirSIDHPubKey
:=
util
.
NewSIDHPublicKey
(
theirVariant
)
theirSIDHPrivKey
.
Generate
(
prng1
)
theirSIDHPrivKey
.
GeneratePublicKey
(
theirSIDHPubKey
)
prng2
:=
rand
.
New
(
rand
.
NewSource
(
int64
(
myID
)))
mySIDHPrivKey
:=
util
.
NewSIDHPrivateKey
(
myVariant
)
mySIDHPubKey
:=
util
.
NewSIDHPublicKey
(
myVariant
)
mySIDHPrivKey
.
Generate
(
prng2
)
mySIDHPrivKey
.
GeneratePublicKey
(
mySIDHPubKey
)
// add the precanned user as a e2e contact
// FIXME: these params need to be threaded through...
sesParam
:=
session
.
GetDefaultParams
()
_
,
err
:=
c
.
e2e
.
AddPartner
(
precan
.
ID
,
precan
.
DhPubKey
,
c
.
e2e
.
GetHistoricalDHPrivkey
(),
theirSIDHPubKey
,
mySIDHPrivKey
,
sesParam
,
sesParam
)
// check garbled messages in case any messages arrived before creating
// the channel
c
.
network
.
CheckInProgressMessages
()
return
precan
,
err
}
// Create an insecure e2e contact object for a precanned user
func
(
c
*
Client
)
MakePrecannedContact
(
precannedID
uint
)
contact
.
Contact
{
e2eGrp
:=
c
.
storage
.
GetE2EGroup
()
precanned
:=
createPrecannedUser
(
precannedID
,
c
.
rng
.
GetStream
(),
c
.
storage
.
GetCmixGroup
(),
e2eGrp
)
// compute their public e2e key
partnerPubKey
:=
e2eGrp
.
ExpG
(
precanned
.
E2eDhPrivateKey
,
e2eGrp
.
NewInt
(
1
))
return
contact
.
Contact
{
ID
:
precanned
.
ReceptionID
,
DhPubKey
:
partnerPubKey
,
OwnershipProof
:
nil
,
Facts
:
make
([]
fact
.
Fact
,
0
),
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment