src/Keypear.Shared/Krypto/PakeServer.cs
/// <summary>
/// Start Registration of a new account.
/// </summary>
Start Registration of a new account.
Start Registration of a new account .
public IPakeServer.RegisterResult Register(IPakeServer.RegisterInput input)
    {
        ThrowIfNull(input.Username);
        ThrowIfNull(input.Verifier);
        ThrowIfNull(input.EphemeralA);
        if (_state.ContainsUsername(input.Username))
        {
            throw new Exception("username already registered");
        }
        var ephA = new BigInteger(input.EphemeralA);
        if (_state.ContainsSession(ephA))
        {
            throw new Exception("ephemeral A already in use");
        }
        var h = ComputeHasher(input.Username);
        var srp = new SrpServer(h,
            _parameters._groupParameters.g,
            _parameters._groupParameters.N);
        var biV = new BigInteger(input.Verifier);
        var ephB = srp.GenerateBValues(biV, out var srpState);
        var pr = new PendingRegistration(input.Username, biV, ephA, ephB, srpState);
        _state.AddPending(input.Username, pr);
        return new()
        {
            EphemeralB = ephB.ToByteArray(),
        };
    }
public IPakeServer . RegisterResult Register ( IPakeServer . RegisterInput input ) { ThrowIfNull ( input . Username ) ; ThrowIfNull ( input . Verifier ) ; ThrowIfNull ( input . EphemeralA ) ; if ( _state . ContainsUsername ( input . Username ) ) { throw new Exception ( " " ) ; } var ephA = new BigInteger ( input . EphemeralA ) ; if ( _state . ContainsSession ( ephA ) ) { throw new Exception ( " " ) ; } var h = ComputeHasher ( input . Username ) ; var srp = new SrpServer ( h , _parameters . _groupParameters . g , _parameters . _groupParameters . N ) ; var biV = new BigInteger ( input . Verifier ) ; var ephB = srp . GenerateBValues ( biV , out var srpState ) ; var pr = new PendingRegistration ( input . Username , biV , ephA , ephB , srpState ) ; _state . AddPending ( input . Username , pr ) ; return new ( ) { EphemeralB = ephB . ToByteArray ( ) , } ; }
Start Registration of a new account.
Start Registration of a new account .
// Make sure username was not already previously registered // Make sure ephA is not already in use, used as a Session state ID // We immediately start preparing a session as a final validation that // the registration succeededed and to have an immediate shared key // Remember the verifier and B for this username
input
IPakeServer.RegisterInput