Java BigInteger Calculate calculateRx_(BigInteger Rx, BigInteger n)

Here you can find the source of calculateRx_(BigInteger Rx, BigInteger n)

Description

A method to calculate the associate value of an ECPoint R, i.e.

License

Apache License

Parameter

Parameter Description

Return

the associate value of ECPoint R, Rx_

Declaration

public static BigInteger calculateRx_(BigInteger Rx, BigInteger n) 

Method Source Code

//package com.java2s;
/**/* w ww . j  a  v a2 s . c o  m*/
 Copyright 2014-2015 Center for TeleInFrastruktur (CTIF), Aalborg University

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 @author Bayu Anggorojati [ba@es.aau.dk]
 Center for TeleInFrastruktur, Aalborg University, Denmark
 */

import java.math.BigInteger;

public class Main {
    /**
     * A method to calculate the associate value of an ECPoint R, i.e. Rx_
     * @param Rx: the x-coordinate of ECPoint R
     * @param n: the order of EC base point
     * @return the associate value of ECPoint R, Rx_
     */
    public static BigInteger calculateRx_(BigInteger Rx, BigInteger n) {
        // work around to calculate log of BigInteger value
        String nStr = n.toString();
        int nLen = nStr.length();

        nStr = "0." + nStr;
        double nDoubKoma = Double.parseDouble(nStr);
        double fDouble = ((double) nLen + Math.log10(nDoubKoma))
                / Math.log10(2.0);
        // ceil of fDouble/2
        fDouble = Math.ceil(fDouble / 2);

        BigInteger coef2 = BigInteger.valueOf(2).pow((int) fDouble);
        BigInteger Rx_ = Rx.mod(coef2).add(coef2);

        return Rx_;
    }
}

Related

  1. base62Encode(BigInteger number)
  2. bitArrayToUnsignedBigInteger(int[] bits)
  3. bitcoinValueToFriendlyString(BigInteger value)
  4. byte_size(BigInteger bi)
  5. calculateGx(BigInteger p, BigInteger g, BigInteger x)
  6. castToBigInteger(Object val)
  7. chop(BigInteger in, int bits)
  8. clip(BigInteger bi, int numberOfBytes)
  9. clone(BigInteger[] data)