src/Keypear.Shared/Krypto/PakeServer.cs
/// <summary>
/// Finish Reigstration a new account and establish a first Session.
/// </summary>
Finish Reigstration a new account and establish a first Session.
Finish Reigstration a new account and establish a first Session .
public IPakeServer.RegisterFiniResult RegisterFini(IPakeServer.RegisterFiniInput input)
    {
        ThrowIfNull(input.Username);
        ThrowIfNull(input.ClientProof);
        if (!_state.TryGetPending(input.Username, out var pr) || pr == null)
        {
            throw new Exception("username not found");
        }
        var h = ComputeHasher(input.Username);
        var srp = new SrpServer(h,
            _parameters._groupParameters.g,
            _parameters._groupParameters.N,
            pr.EphemeralB, pr.SrpState);
        var sKey = srp.ComputeSessionKey(pr.Verifier, pr.EphemeralA);
        var cProof = new BigInteger(input.ClientProof);
        if (!srp.ValidateClientProof(cProof, pr.EphemeralA, sKey))
        {
            throw new Exception("client proof is invalid");
        }
        var sProof = srp.GenerateServerProof(pr.EphemeralA, cProof, sKey);
        _state.RemovePending(input.Username);
        _state.AddVerifier(input.Username, pr.Verifier);
        return new()
        {
            ServerProof = sProof.ToByteArray(),
        };
    }
public IPakeServer . RegisterFiniResult RegisterFini ( IPakeServer . RegisterFiniInput input ) { ThrowIfNull ( input . Username ) ; ThrowIfNull ( input . ClientProof ) ; if ( ! _state . TryGetPending ( input . Username , out var pr ) || pr == null ) { throw new Exception ( " " ) ; } var h = ComputeHasher ( input . Username ) ; var srp = new SrpServer ( h , _parameters . _groupParameters . g , _parameters . _groupParameters . N , pr . EphemeralB , pr . SrpState ) ; var sKey = srp . ComputeSessionKey ( pr . Verifier , pr . EphemeralA ) ; var cProof = new BigInteger ( input . ClientProof ) ; if ( ! srp . ValidateClientProof ( cProof , pr . EphemeralA , sKey ) ) { throw new Exception ( " " ) ; } var sProof = srp . GenerateServerProof ( pr . EphemeralA , cProof , sKey ) ; _state . RemovePending ( input . Username ) ; _state . AddVerifier ( input . Username , pr . Verifier ) ; return new ( ) { ServerProof = sProof . ToByteArray ( ) , } ; }
Finish Reigstration a new account and establish a first Session.
Finish Reigstration a new account and establish a first Session .
input
IPakeServer.RegisterFiniInput