コード例 #1
0
    // Checks to see if the seed is within demo parameters. For demo use only
    public byte[] checkSeed(byte[] seed)
    {
        int checkVal = OTPworker.checkValidSeed(seedToByte.getActionsFromBytes(seed));

        while (checkVal > 1)
        {
            Debug.Log("Generating new seed");
            for (int i = 0; i < seed.Length; i++)
            {
                if (seed[i] > 0)
                {
                    seed[i] -= 1;
                }
            }
            checkVal = OTPworker.checkValidSeed(seedToByte.getActionsFromBytes(seed));
        }
        return(seed);
    }
コード例 #2
0
    public int[] getActionsFromSentence(string sentence)
    {
        int[]    actions   = new int[1];
        string[] wordArray = sentence.Split(null);

        if (wordArray.Length < 12)
        {
            Debug.Log("Not enough words for 132 bits of entropy.");
            throw new Exception("Less than 12 words in this sentence. Not a valid seed.");
        }

        List <int> indeces = rebuildWordIndexes(wordArray);

        byte[]     bytes         = processWordIndecesNoChecksum(indeces);
        List <int> wordListSizes = new List <int> {
            11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
        };

        actions = seeds.getActionsFromBytes(bytes);
        return(actions);
    }