class Ed25519EncodedFieldElement implements Serializable {

  public Ed25519FieldElement decode() {
    long h0 = fourBytesToLong(this.values, 0);
    long h1 = threeBytesToLong(this.values, 4) << 6;
    long h2 = threeBytesToLong(this.values, 7) << 5;
    long h3 = threeBytesToLong(this.values, 10) << 3;
    long h4 = threeBytesToLong(this.values, 13) << 2;
    long h5 = fourBytesToLong(this.values, 16);
    long h6 = threeBytesToLong(this.values, 20) << 7;
    long h7 = threeBytesToLong(this.values, 23) << 5;
    long h8 = threeBytesToLong(this.values, 26) << 4;
    long h9 = (threeBytesToLong(this.values, 29) & 0x7FFFFF) << 2;
    final long carry0;
    final long carry1;
    final long carry2;
    final long carry3;
    final long carry4;
    final long carry5;
    final long carry6;
    final long carry7;
    final long carry8;
    final long carry9;

    // Remember: 2^255 congruent 19 modulo p
    carry9 = (h9 + (long) (1 << 24)) >> 25;
    h0 += carry9 * 19;
    h9 -= carry9 << 25;
    carry1 = (h1 + (long) (1 << 24)) >> 25;
    h2 += carry1;
    h1 -= carry1 << 25;
    carry3 = (h3 + (long) (1 << 24)) >> 25;
    h4 += carry3;
    h3 -= carry3 << 25;
    carry5 = (h5 + (long) (1 << 24)) >> 25;
    h6 += carry5;
    h5 -= carry5 << 25;
    carry7 = (h7 + (long) (1 << 24)) >> 25;
    h8 += carry7;
    h7 -= carry7 << 25;

    carry0 = (h0 + (long) (1 << 25)) >> 26;
    h1 += carry0;
    h0 -= carry0 << 26;
    carry2 = (h2 + (long) (1 << 25)) >> 26;
    h3 += carry2;
    h2 -= carry2 << 26;
    carry4 = (h4 + (long) (1 << 25)) >> 26;
    h5 += carry4;
    h4 -= carry4 << 26;
    carry6 = (h6 + (long) (1 << 25)) >> 26;
    h7 += carry6;
    h6 -= carry6 << 26;
    carry8 = (h8 + (long) (1 << 25)) >> 26;
    h9 += carry8;
    h8 -= carry8 << 26;

    final int[] h = new int[10];
    h[0] = (int) h0;
    h[1] = (int) h1;
    h[2] = (int) h2;
    h[3] = (int) h3;
    h[4] = (int) h4;
    h[5] = (int) h5;
    h[6] = (int) h6;
    h[7] = (int) h7;
    h[8] = (int) h8;
    h[9] = (int) h9;

    return new Ed25519FieldElement(h);
  }

  public  Ed25519EncodedFieldElement(final byte[] values);

}