Commit ff32a341 authored by David Stainton's avatar David Stainton

java: use wrapper for ecdh keys

parent 9d5834d7
// key.go - mixnet user key
// Copyright (C) 2017 Yawning Angel.
// Copyright (C) 2017 Ruben Pollan.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <>.
package client
import (
// Key keeps the key public and private data
type Key struct {
priv *ecdh.PrivateKey
// GenKey creates a new ecdh key
func GenKey() (*Key, error) {
mKey := new(Key)
var err error
mKey.priv, err = ecdh.NewKeypair(rand.Reader)
if err != nil {
return mKey, err
return mKey, err
......@@ -54,13 +54,13 @@ type Session struct {
// NewSession stablishes a session with provider using key
func (c *KatzenClient) NewSession(user string, provider string, linkPrivKey *ecdh.PrivateKey) (*Session, error) {
func (c *KatzenClient) NewSession(user string, provider string, linkPrivKey *Key) (*Session, error) {
var err error
session := new(Session)
clientCfg := &client.Config{
User: user,
Provider: provider,
LinkKey: linkPrivKey,
LinkKey: linkPrivKey.priv,
LogBackend: c.log,
PKIClient: c.pki,
......@@ -107,11 +107,11 @@ func (s *Session) Get(identity string) (*ecdh.PublicKey, error) {
// Connect connects the client to the Provider
func (s *Session) Connect(identityPrivKey *ecdh.PrivateKey) error {
func (s *Session) Connect(identityPrivKey *Key) error {
sessionCfg := client.SessionConfig{
User: s.clientCfg.User,
Provider: s.clientCfg.Provider,
IdentityPrivKey: identityPrivKey,
IdentityPrivKey: identityPrivKey.priv,
LinkPrivKey: s.clientCfg.LinkKey,
MessageConsumer: s,
Storage: new(StorageStub),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment