Пример #1
0
        public ECPoint RandomizeToken(AnonymousTokenState state, GenerateTokenResponseModel tokenResponse, ECPoint K)
        {
            var Q = _ecParameters.Curve.DecodePoint(Convert.FromBase64String(tokenResponse.SignedPoint));
            var c = new BigInteger(Convert.FromBase64String(tokenResponse.ProofChallenge));
            var z = new BigInteger(Convert.FromBase64String(tokenResponse.ProofResponse));

            return(_initiator.RandomiseToken(_ecParameters, K, state.P, Q, c, z, state.r));
        }
Пример #2
0
        public ECPoint RandomizeToken(AnonymousTokenState state, GenerateTokenResponseModel tokenResponse, ECPublicKeyParameters K)
        {
            var Q = _ecParameters.Curve.DecodePoint(Hex.Decode(tokenResponse.QAsHex));
            var c = new BigInteger(Hex.Decode(tokenResponse.ProofCAsHex));
            var z = new BigInteger(Hex.Decode(tokenResponse.ProofZAsHex));

            return(_initiator.RandomiseToken(_ecParameters, K, state.P, Q, c, z, state.r));
        }
Пример #3
0
        private async Task <GenerateTokenResponseModel> RequestTokenGeneration(AnonymousTokenState state)
        {
            var request = new HttpRequestMessage(HttpMethod.Post, OAuthConf.OAUTH2_ANONTOKEN_URL);

            request.Headers.Add("Authorization", $"Bearer {AuthenticationState.PersonalData?.Access_token}");
            var tokenRequest = new GenerateTokenRequestModel
            {
                MaskedPoint = Convert.ToBase64String(state.P.GetEncoded())
            };

            request.Content = new StringContent(JsonConvert.SerializeObject(tokenRequest), Encoding.UTF8, "application/json");
            var response = await new HttpClient().SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                throw new WebServiceHttpException(response, OAuthConf.OAUTH2_ANONTOKEN_URL);
            }
            return(JsonConvert.DeserializeObject <GenerateTokenResponseModel>(await response.Content.ReadAsStringAsync()));
        }
Пример #4
0
        string EncodeToken(AnonymousTokenState tokenState, ECPoint W, string keyId)
        {
            var t = tokenState.t;

            return(Convert.ToBase64String(W.GetEncoded()) + "." + Convert.ToBase64String(t) + "." + keyId);
        }