// // Validates a User representation of a Factom and // Entry Credit addresses. // // Returns false if the length is wrong. // Returns false if the prefix is wrong. // Returns false if the checksum is wrong. // func validateUserStr(prefix []byte, userFAddr string) bool { if len(userFAddr) != 52 { return false } v := base58.Decode(userFAddr) if bytes.Compare(prefix, v[:2]) != 0 { return false } sha256d := Sha(Sha(v[:34]).Bytes()).Bytes() if bytes.Compare(sha256d[:4], v[34:]) != 0 { return false } return true }
// Convert a User facing Factoid or Entry Credit address // or their Private Key representations // to the regular form. Note validation must be done // separately! func ConvertUserStrToAddress(userFAddr string) []byte { v := base58.Decode(userFAddr) return v[2:34] }